Migration

DEP0169: migrate legacy url.parse

Replace legacy URL parsing with the standardized WHATWG API. Review relative URL handling, credentials and hostname validation during migration; parsing alone does not enforce a network policy. Tested on Node.js 22.16.0. Example output (one line per entry): ["example.invalid a,b"].

Formal Syntax & Structure

nodejs syntaxnodejs
new URL(input[, base])

Return Value

Migration outcome

Replacement behavior shown by the example.

Working Example

Example Snippetnodejs
const u = new URL('/catalog?tag=a&tag=b', 'https://example.invalid');console.log(u.hostname, u.searchParams.getAll('tag').join(','));
Node.js Reference