Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url: validate argument length in URL and canParse #47513

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/internal/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,10 @@ class URL {
}

static canParse(url, base = undefined) {
if (arguments.length === 0) {
throw new ERR_MISSING_ARGS('url');
}

url = `${url}`;

if (base !== undefined) {
Expand Down
12 changes: 12 additions & 0 deletions test/parallel/test-url-canParse-whatwg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

Check failure on line 1 in test/parallel/test-url-canParse-whatwg.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected linebreaks to be 'LF' but found 'CRLF'

Check failure on line 2 in test/parallel/test-url-canParse-whatwg.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected linebreaks to be 'LF' but found 'CRLF'
require('../common');

Check failure on line 3 in test/parallel/test-url-canParse-whatwg.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected linebreaks to be 'LF' but found 'CRLF'
const assert = require('assert');

Check failure on line 4 in test/parallel/test-url-canParse-whatwg.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected linebreaks to be 'LF' but found 'CRLF'

Check failure on line 5 in test/parallel/test-url-canParse-whatwg.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected linebreaks to be 'LF' but found 'CRLF'
// One argument is required

Check failure on line 6 in test/parallel/test-url-canParse-whatwg.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected linebreaks to be 'LF' but found 'CRLF'
assert.throws(() => {

Check failure on line 7 in test/parallel/test-url-canParse-whatwg.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected linebreaks to be 'LF' but found 'CRLF'
URL.canParse();

Check failure on line 8 in test/parallel/test-url-canParse-whatwg.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected linebreaks to be 'LF' but found 'CRLF'
}, {

Check failure on line 9 in test/parallel/test-url-canParse-whatwg.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected linebreaks to be 'LF' but found 'CRLF'
code: 'ERR_MISSING_ARGS',

Check failure on line 10 in test/parallel/test-url-canParse-whatwg.js

View workflow job for this annotation

GitHub Actions / lint-js-and-md

Expected linebreaks to be 'LF' but found 'CRLF'
name: 'TypeError'
});