GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — url: validate argument length in canParse · nodejs/node@bf4ee17

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal
    • url.js
  • test/parallel
    • test-url-canParse-whatwg.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/url.js‎

Copy file name to clipboardExpand all lines: lib/internal/url.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,6 +964,10 @@ class URL {
964964
}
965965

966966
static canParse(url, base = undefined) {
967+
if (arguments.length === 0) {
968+
throw new ERR_MISSING_ARGS('url');
969+
}
970+
967971
url = `${url}`;
968972

969973
if (base !== undefined) {
Collapse file

‎test/parallel/test-url-canParse-whatwg.js‎

Copy file name to clipboard
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
require('../common');
4+
const assert = require('assert');
5+
6+
// One argument is required
7+
assert.throws(() => {
8+
URL.canParse();
9+
}, {
10+
code: 'ERR_MISSING_ARGS',
11+
name: 'TypeError'
12+
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.