We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5d7f895 commit c24cd22Copy full SHA for c24cd22
1 file changed
lib/util/url.js
@@ -23,7 +23,21 @@ let urlDecodePatterns = [
23
];
24
25
exports.parse = require("url").parse;
26
-exports.resolve = require("url").resolve;
+
27
+/**
28
+ * Returns resolved target URL relative to a base URL in a manner similar to that of a Web browser resolving an anchor tag HREF.
29
+ *
30
+ * @return {string}
31
+ */
32
+exports.resolve = function resolve (from, to) {
33
+ let resolvedUrl = new URL(to, new URL(from, "resolve://"));
34
+ if (resolvedUrl.protocol === "resolve:") {
35
+ // `from` is a relative URL.
36
+ let { pathname, search, hash } = resolvedUrl;
37
+ return pathname + search + hash;
38
+ }
39
+ return resolvedUrl.toString();
40
+};
41
42
/**
43
* Returns the current working directory (in Node) or the current page URL (in browsers).
0 commit comments