From 5a775b3b9e70051395c1a2d748603076ff9040d6 Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Thu, 4 Jul 2024 22:51:03 -0400 Subject: [PATCH] url: add missing documentation for `URL.parse()` PR-URL: https://github.com/nodejs/node/pull/53733 Reviewed-By: Matthew Aitken Reviewed-By: James M Snell --- doc/api/url.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/doc/api/url.md b/doc/api/url.md index 53484e1a856395..60e9a02bd6c61a 100644 --- a/doc/api/url.md +++ b/doc/api/url.md @@ -691,6 +691,23 @@ const isValid = URL.canParse('/foo', 'https://example.org/'); // true const isNotValid = URL.canParse('/foo'); // false ``` +#### `URL.parse(input[, base])` + + + +* `input` {string} The absolute or relative input URL to parse. If `input` + is relative, then `base` is required. If `input` is absolute, the `base` + is ignored. If `input` is not a string, it is [converted to a string][] first. +* `base` {string} The base URL to resolve against if the `input` is not + absolute. If `base` is not a string, it is [converted to a string][] first. +* Returns: {URL|null} + +Parses a string as a URL. If `base` is provided, it will be used as the base +URL for the purpose of resolving non-absolute `input` URLs. Returns `null` +if `input` is not a valid. + ### Class: `URLSearchParams`