Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created January 2, 2010 21:52
Show Gist options
  • Save isaacs/267693 to your computer and use it in GitHub Desktop.
Save isaacs/267693 to your computer and use it in GitHub Desktop.
---- PARSE TESTS ----
uri fail http://example.com?foo=@bar#frag
expected:
{"href":"http://example.com?foo=@bar#frag","protocol":"http:","host":"example.com","hostname":"example.com","hash":"#frag","search":"?foo=@bar","query":"foo=@bar"}
actual:
{"href":"http://example.com?foo=@bar#frag","protocol":"http:","host":"example.com?foo=@bar","hostname":"bar","hash":"#frag","query":""}
---- RESOLVE TESTS ----
uri fail foo/bar + ../../../baz
expected: ../../baz
actual: az
uri fail foo/bar/ + ../../../baz
expected: ../baz
actual: az
uri fail http://u:[email protected]/p/a/t/h?s#hash + https:#hash2
expected: https://u:[email protected]/p/a/t/h?s#hash2
actual: https:#hash2
uri fail http://u:[email protected]/p/a/t/h?s#hash + https:/p/a/t/h?s#hash2
expected: https://u:[email protected]/p/a/t/h?s#hash2
actual: https:/p/a/t/h?s#hash2
uri fail http://u:[email protected]/p/a/t/h?s#hash + https:/a/b/c/d
expected: https://u:[email protected]/a/b/c/d
actual: https:/a/b/c/d
---- FORMAT TESTS ----
uri fail http://example.com?foo=bar#frag
expected: http://example.com?foo=bar#frag
actual: http://example.com/?foo=bar#frag
uri fail http://example.com?foo=@bar#frag
expected: http://example.com?foo=@bar#frag
actual: http://example.com?foo=@bar/#frag
uri fail http://example.com?foo=/bar/#frag
expected: http://example.com?foo=/bar/#frag
actual: http://example.com/?foo=/bar/#frag
uri fail http://example.com?foo=?bar/#frag
expected: http://example.com?foo=?bar/#frag
actual: http://example.com/?foo=?bar/#frag
uri fail http://example.com#frag=?bar/#frag
expected: http://example.com#frag=?bar/#frag
actual: http://example.com/#frag=?bar/#frag
uri fail mailto:[email protected]?subject=hello
expected: mailto:[email protected]?subject=hello
actual: mailto:[email protected]?subject=hello
uri fail javascript:alert('hello');
expected: javascript:alert('hello');
actual: javascript:lert('hello');
uri fail xmpp://[email protected]
expected: xmpp://[email protected]
actual: xmpp://[email protected]/
---- PARSE SPEED TESTS ----
....................
Scores: (higher is better)
Narwhal URI Module (with big regex and many fields):
18.069
17.571711177052425
19.057
18.544
18.468
18.658
17.56949806949807
18.601
18.525
18.772227772227772
MEAN: 18.383543701877826
New URL Module (with minimal regexes and few fields):
198.987
202.578
201.69230769230768
206.473
201.571
206.739
204.516
205.12787212787214
203.49
209
MEAN: 204.017417982018
---- RESOLVE SPEED TESTS ----
....................
Scores: (higher is better)
Narwhal URI Module (with big regex and many fields):
7.496503496503497
7.408
8.151848151848151
7.72027972027972
7.936
8.055944055944057
7.736263736263736
8.055944055944057
7.473053892215569
8.359640359640359
MEAN: 7.8393477468639166
New URL Module (with minimal regexes and few fields):
13.698301698301698
14.144
14.24
14.032
13.696
13.45854145854146
12.576
13.077986179664363
13.168
12.963036963036963
MEAN: 13.505386629954447
---- FORMAT SPEED TESTS ----
....................
Scores: (higher is better)
Narwhal URI Module (with big regex and many fields):
327.427
345.401
334.4455544455544
358.796
347.871
359.651
341.392
358.036
356.25
360.24
MEAN: 348.95095544455546
New URL Module (with minimal regexes and few fields):
474.0443786982249
549.119
473.005
533.653
487.17217217217217
548.378
474.886
521.037
475.513
537.244
MEAN: 507.40515508703965
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment