URL Parsing (v23)

Revision 23 of this benchmark created by gnumanth on


Setup

var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;
  var elmA = document.createElement('a');
  var url = "http://jblas:password@mycompany.com:8080/mail/inbox?msg=1234&type=unread#msg-content";

Test runner

Ready to run.

Testing in
TestOps/sec
Regex
var matches = urlParseRE.exec(url);
var hostname1 = matches[11];
var search1 = matches[16];
ready
Native
elmA.href = url;
var hostname2 = elmA.hostname;
var search2 = elmA.search;
ready
URL API
new URL(url);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.