-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #563 from geonetwork/misc-fixes-for-1.1-2
Another batch of fixes for 1.1.0 release
- Loading branch information
Showing
9 changed files
with
93 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { removeSearchParams } from './url' | ||
|
||
describe('URL utils', () => { | ||
describe('removeSearchParams', () => { | ||
it('removes given search params in a case insensitive way', () => { | ||
expect( | ||
removeSearchParams( | ||
'http://my.org/abc/?arg0=1234&arg1=aaa&Arg1=111&ARG2=&aRG3=fff&arg4=5678', | ||
['ARG1', 'arg2', 'arg3'] | ||
) | ||
).toEqual('http://my.org/abc/?arg0=1234&arg4=5678') | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Removes the given search params from the URL completely; this is case-insensitive | ||
* @param url | ||
* @param searchParams | ||
*/ | ||
export function removeSearchParams( | ||
url: string, | ||
searchParams: string[] | ||
): string { | ||
const toDelete = [] | ||
const urlObj = new URL(url, window.location.toString()) | ||
const keysLower = searchParams.map((p) => p.toLowerCase()) | ||
for (const param of urlObj.searchParams.keys()) { | ||
if (keysLower.indexOf(param.toLowerCase()) > -1) { | ||
toDelete.push(param) | ||
} | ||
} | ||
toDelete.map((param) => urlObj.searchParams.delete(param)) | ||
return urlObj.toString() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters