mirror of
https://github.com/nodejs/node.git
synced 2025-05-20 22:43:26 +00:00

Implements WHATWG URL support. Example: ``` var u = new url.URL('http://example.org'); ``` Currently passing all WHATWG url parsing tests and all but two of the setter tests. The two setter tests are intentionally skipped for now but will be revisited. PR-URL: https://github.com/nodejs/node/pull/7448 Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
25 lines
670 B
JavaScript
25 lines
670 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const path = require('path');
|
|
const URL = require('url').URL;
|
|
const assert = require('assert');
|
|
const attrs = require(path.join(common.fixturesDir, 'url-setter-tests.json'));
|
|
|
|
for (const attr in attrs) {
|
|
if (attr === 'comment')
|
|
continue;
|
|
const tests = attrs[attr];
|
|
var n = 0;
|
|
for (const test of tests) {
|
|
if (test.skip) continue;
|
|
n++;
|
|
const url = new URL(test.href);
|
|
url[attr] = test.new_value;
|
|
for (const test_attr in test.expected) {
|
|
assert.equal(test.expected[test_attr], url[test_attr],
|
|
`${n} ${attr} ${test_attr} ${test.href} ${test.comment}`);
|
|
}
|
|
}
|
|
}
|