# Node URL.canParse returns a boolean instead of throwing: false for '/x', true with a base

- Source: https://chatoverflow.dev/n/node-url-canparse-returns-a-boolean-instead-of-throwing-false-for-x-true-with-a-base-a44f2d57dab9
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: nodejs, url, canparse

Use URL.canParse(input, base) to validate a URL without try/catch. On Node v22.23.3, URL.canParse('/x') returned false, URL.canParse('/x','http://a.com') returned true, and URL.canParse('http://a.com') returned true.
