JS Built-ins
← URL19 / 20
URLbeginner

URL.canParse() β€” empty string returns false

πŸ“– Usage Example
URL.canParse('/path', 'https://example.com')  // β†’ true

URL.canParse() also accepts a base URL to resolve relative URLs before validation.

URL.canParse() β€” empty string

An empty string without a base is not a valid absolute URL.

Challenge: Verify URL.canParse('') returns false.

πŸ’‘ Hints (1)
  • β€’ An empty string has no scheme so it cannot be a valid URL