|
1 | 1 | 'use strict'; |
2 | | -var common = require('../common.js'); |
3 | | -var url = require('url'); |
4 | | -var v8 = require('v8'); |
| 2 | +const common = require('../common.js'); |
| 3 | +const url = require('url'); |
| 4 | +const v8 = require('v8'); |
| 5 | +const hrefs = require('../fixtures/url-inputs.js').urls; |
| 6 | +hrefs.noscheme = 'some.ran/dom/url.thing?oh=yes#whoo'; |
5 | 7 |
|
6 | | -var hrefs = [ |
7 | | - 'http://example.com/', |
8 | | - 'http://nodejs.org/docs/latest/api/url.html#url_url_format_urlobj', |
9 | | - 'http://blog.nodejs.org/', |
10 | | - 'https://encrypted.google.com/search?q=url&q=site:npmjs.org&hl=en', |
11 | | - 'javascript:alert("node is awesome");', |
12 | | - 'some.ran/dom/url.thing?oh=yes#whoo' |
13 | | -]; |
| 8 | +const paths = { |
| 9 | + 'up': '../../../../../etc/passwd', |
| 10 | + 'sibling': '../foo/bar?baz=boom', |
| 11 | + 'foo/bar': 'foo/bar', |
| 12 | + 'withscheme': 'http://nodejs.org', |
| 13 | + 'down': './foo/bar?baz' |
| 14 | +}; |
14 | 15 |
|
15 | | - |
16 | | -var paths = [ |
17 | | - '../../../../../etc/passwd', |
18 | | - '../foo/bar?baz=boom', |
19 | | - 'foo/bar', |
20 | | - 'http://nodejs.org', |
21 | | - './foo/bar?baz' |
22 | | -]; |
23 | | - |
24 | | -var bench = common.createBenchmark(main, { |
| 16 | +const bench = common.createBenchmark(main, { |
25 | 17 | href: Object.keys(hrefs), |
26 | 18 | path: Object.keys(paths), |
27 | 19 | n: [1e5] |
28 | 20 | }); |
29 | 21 |
|
30 | 22 | function main(conf) { |
31 | | - var n = conf.n | 0; |
32 | | - var href = hrefs[conf.href]; |
33 | | - var path = paths[conf.path]; |
| 23 | + const n = conf.n | 0; |
| 24 | + const href = hrefs[conf.href]; |
| 25 | + const path = paths[conf.path]; |
34 | 26 |
|
35 | 27 | // Force-optimize url.resolve() so that the benchmark doesn't get |
36 | 28 | // disrupted by the optimizer kicking in halfway through. |
|
0 commit comments