Created
November 5, 2019 19:13
-
-
Save qwtel/84be84255e335b7706841a2332af0a97 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| export const urlWithParams = (url, params) => { | |
| const u = new URL(url, global.location.origin) | |
| if (params) { | |
| u.search = new URLSearchParams([...u.searchParams, ...Object.entries(params)]) | |
| } | |
| return u.href | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: You might have to replace
globalwithwindow,self, orglobalThisdepending on use context.