Skip to content

Commit 85bcecc

Browse files
authored
feat: use new URL
1 parent a244fb0 commit 85bcecc

1 file changed

Lines changed: 12 additions & 10 deletions

File tree

src/utils/getFilenameFromUrl.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
const path = require("node:path");
22
const querystring = require("node:querystring");
3-
// eslint-disable-next-line n/no-deprecated-api
4-
const { parse } = require("node:url");
53

64
const getPaths = require("./getPaths");
75
const memorize = require("./memorize");
@@ -17,13 +15,17 @@ function decode(input) {
1715
return querystring.unescape(input);
1816
}
1917

20-
const memoizedParse = memorize(parse, undefined, (value) => {
21-
if (value.pathname) {
22-
value.pathname = decode(value.pathname);
23-
}
18+
const memoizedParse = memorize(
19+
(url) => new URL(url, "http://localhost"),
20+
undefined,
21+
(value) => {
22+
if (value.pathname) {
23+
value.pathname = decode(value.pathname);
24+
}
2425

25-
return value;
26-
});
26+
return value;
27+
},
28+
);
2729

2830
const UP_PATH_REGEXP = /(?:^|[\\/])\.\.(?:[\\/]|$)/;
2931

@@ -59,7 +61,7 @@ function getFilenameFromUrl(context, url) {
5961
let foundFilename;
6062
/** @type {number | undefined} */
6163
let errorCode;
62-
/** @type {import("node:url").Url} */
64+
/** @type {import("node:url").URL} */
6365
let urlObject;
6466

6567
try {
@@ -72,7 +74,7 @@ function getFilenameFromUrl(context, url) {
7274
for (const { publicPath, outputPath, assetsInfo } of paths) {
7375
/** @type {string | undefined} */
7476
let filename;
75-
/** @type {import("node:url").Url} */
77+
/** @type {import("node:url").URL} */
7678
let publicPathObject;
7779

7880
try {

0 commit comments

Comments
 (0)