Skip to content

Commit

Permalink
refactor: replace url.parse with new URL
Browse files Browse the repository at this point in the history
`url.parse` is deprecated, `new URL` is supported since Node v10.
  • Loading branch information
CanadaHonk committed Oct 17, 2023
1 parent 1a5a675 commit b75afa1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions markdown-link-check
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ function getInputs() {
stream.on('error', onError);
stream.on('response', onResponse);
try { // extract baseUrl from supplied URL
const parsed = url.parse(filenameOrUrl);
delete parsed.search;
delete parsed.hash;
const parsed = new URL(filenameOrUrl);
parsed.search = '';
parsed.hash = '';
if (parsed.pathname.lastIndexOf('/') !== -1) {
parsed.pathname = parsed.pathname.substr(0, parsed.pathname.lastIndexOf('/') + 1);
}
baseUrl = url.format(parsed);
baseUrl = parsed.toString();
} catch (err) { /* ignore error */
}
} else {
Expand Down

0 comments on commit b75afa1

Please sign in to comment.