File tree Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Expand file tree Collapse file tree 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,21 @@ let urlDecodePatterns = [
2323] ;
2424
2525exports . parse = require ( "url" ) . parse ;
26- exports . resolve = require ( "url" ) . resolve ;
26+
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+ } ;
2741
2842/**
2943 * Returns the current working directory (in Node) or the current page URL (in browsers).
You can’t perform that action at this time.
0 commit comments