File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed
Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 1- import { createURL } from "./url" ;
21import { parseURL , stringifyParsedURL } from "./parse" ;
32import { QueryObject , parseQuery , stringifyQuery , ParsedQuery } from "./query" ;
4- import { decode } from "./encoding" ;
3+ import {
4+ decode ,
5+ decodePath ,
6+ encodeHash ,
7+ encodeHost ,
8+ encodeParam ,
9+ encodePath ,
10+ } from "./encoding" ;
511
612export function isRelative ( inputString : string ) {
713 return [ "./" , "../" ] . some ( ( string_ ) => inputString . startsWith ( string_ ) ) ;
@@ -212,8 +218,12 @@ export function withProtocol(input: string, protocol: string): string {
212218}
213219
214220export function normalizeURL ( input : string ) : string {
215- // TODO: remove dependecny on createURL
216- return createURL ( input ) . toString ( ) ;
221+ const parsed = parseURL ( input ) ;
222+ parsed . pathname = encodePath ( decodePath ( parsed . pathname ) ) ;
223+ parsed . hash = encodeHash ( decode ( parsed . hash ) ) ;
224+ parsed . host = encodeHost ( decode ( parsed . host ) ) ;
225+ parsed . search = stringifyQuery ( parseQuery ( parsed . search ) ) ;
226+ return stringifyParsedURL ( parsed ) ;
217227}
218228
219229export function resolveURL ( base = "" , ...inputs : string [ ] ) : string {
You can’t perform that action at this time.
0 commit comments