File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed
packages/shared/src/utils Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -225,6 +225,12 @@ describe('truncateFileName', () => {
225
225
expect ( result ) . toBe ( '/some/path/' ) ;
226
226
} ) ;
227
227
228
+ it ( 'should remove localhost from href but keeps the query and hash' , ( ) => {
229
+ const href = 'http://localhost:3000/some/path/?query=value#fragment' ;
230
+ const result = removeLocalhostFromBaseUrl ( href ) ;
231
+ expect ( result ) . toBe ( '/some/path/?query=value#fragment' ) ;
232
+ } ) ;
233
+
228
234
it ( 'should remove localhost from href' , ( ) => {
229
235
const href = 'http://localhost:3000/' ;
230
236
const result = removeLocalhostFromBaseUrl ( href ) ;
@@ -236,6 +242,7 @@ describe('truncateFileName', () => {
236
242
const result = removeLocalhostFromBaseUrl ( href ) ;
237
243
expect ( result ) . toBe ( '/some/path/' ) ;
238
244
} ) ;
245
+
239
246
it ( 'should return the exact href if locahost is not the host name' , ( ) => {
240
247
const href = 'https://www.example.com/' ;
241
248
const result = removeLocalhostFromBaseUrl ( href ) ;
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ export const removeLocalhostFromBaseUrl = (href: string) => {
104
104
try {
105
105
baseUrl = new URL ( href ) ;
106
106
if ( baseUrl . hostname === 'localhost' ) {
107
- return baseUrl . pathname ;
107
+ return baseUrl . pathname + baseUrl . search + baseUrl . hash ;
108
108
}
109
109
return href ;
110
110
} catch ( error ) {
You can’t perform that action at this time.
0 commit comments