File tree 1 file changed +4
-2
lines changed
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ export type QueryValue =
9
9
| undefined ;
10
10
export type QueryObject = Record < string , QueryValue | QueryValue [ ] > ;
11
11
12
+ const DEFAULT_BASE_URL = "http://localhost" ;
13
+
12
14
/**
13
15
* Removes the leading slash from the given path if it has one.
14
16
*/
@@ -80,7 +82,7 @@ export function withQuery(input: string, query: QueryObject): string {
80
82
let searchParams : URLSearchParams ;
81
83
82
84
if ( input . includes ( "?" ) ) {
83
- url = new URL ( input , "http://localhost" ) ;
85
+ url = new URL ( input , DEFAULT_BASE_URL ) ;
84
86
searchParams = new URLSearchParams ( url . search ) ;
85
87
} else {
86
88
searchParams = new URLSearchParams ( ) ;
@@ -109,7 +111,7 @@ export function withQuery(input: string, query: QueryObject): string {
109
111
if ( url ) {
110
112
url . search = queryString ;
111
113
let urlWithQuery = url . toString ( ) ;
112
- if ( urlWithQuery . startsWith ( "http://localhost" ) ) {
114
+ if ( urlWithQuery . startsWith ( DEFAULT_BASE_URL ) ) {
113
115
urlWithQuery = urlWithQuery . slice ( 16 ) ;
114
116
}
115
117
return urlWithQuery ;
You can’t perform that action at this time.
0 commit comments