URL Parsing (v33)

Revision 33 of this benchmark created on


Preparation HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/URI.js/1.15.1/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
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
URI.js
var uri = new URI(url);
var hostname3 = uri.hostname();
var search3 = uri.search();
ready

Revisions

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