URL Parsing (v34)

Revision 34 of this benchmark created on


Preparation HTML

<script src="https://raw.githubusercontent.com/medialize/URI.js/gh-pages/src/URI.min.js"></script>

Setup

var urlParseRE = /^(((([^:\/#\?]+:)?(?:(\/\/)((?:(([^:@\/#\?]+)(?:\:([^:@\/#\?]+))?)@)?(([^:\/#\?\]\[]+|\[[^\/\]@#?]+\])(?:\:([0-9]+))?))?)?)?((\/?(?:[^\/\?#]+\/+)*)([^\?#]*)))?(\?[^#]+)?)(#.*)?/;
  var parser = 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
URI.js
var uri = new URI(url);
var hostname3 = uri.hostname();
var search3 = uri.search();
ready
Regex
var matches = urlParseRE.exec(url);
var hostname1 = matches[11];
var search1 = matches[16];
ready
Native
parser.href = url;
var hostname2 = parser.hostname;
var search2 = parser.search;
ready

Revisions

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