diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-18 14:18:50 +0300 |
commit | 8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch) | |
tree | a77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/assets/javascripts/lib/utils/url_utility.js | |
parent | 00b35af3db1abfe813a778f643dad221aad51fca (diff) |
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/assets/javascripts/lib/utils/url_utility.js')
-rw-r--r-- | app/assets/javascripts/lib/utils/url_utility.js | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/app/assets/javascripts/lib/utils/url_utility.js b/app/assets/javascripts/lib/utils/url_utility.js index 966e6d42b80..0472b8cf51f 100644 --- a/app/assets/javascripts/lib/utils/url_utility.js +++ b/app/assets/javascripts/lib/utils/url_utility.js @@ -109,9 +109,10 @@ export function mergeUrlParams(params, url) { * * @param {string[]} params - the query param names to remove * @param {string} [url=windowLocation().href] - url from which the query param will be removed + * @param {boolean} skipEncoding - set to true when the url does not require encoding * @returns {string} A copy of the original url but without the query param */ -export function removeParams(params, url = window.location.href) { +export function removeParams(params, url = window.location.href, skipEncoding = false) { const [rootAndQuery, fragment] = url.split('#'); const [root, query] = rootAndQuery.split('?'); @@ -119,12 +120,13 @@ export function removeParams(params, url = window.location.href) { return url; } - const encodedParams = params.map(param => encodeURIComponent(param)); + const removableParams = skipEncoding ? params : params.map(param => encodeURIComponent(param)); + const updatedQuery = query .split('&') .filter(paramPair => { const [foundParam] = paramPair.split('='); - return encodedParams.indexOf(foundParam) < 0; + return removableParams.indexOf(foundParam) < 0; }) .join('&'); @@ -242,6 +244,15 @@ export function isRootRelative(url) { } /** + * Returns true if url is a base64 data URL + * + * @param {String} url + */ +export function isBase64DataUrl(url) { + return /^data:[.\w+-]+\/[.\w+-]+;base64,/.test(url); +} + +/** * Returns true if url is an absolute or root-relative URL * * @param {String} url |