summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorScott Escue <scott.escue@gmail.com>2018-12-02 00:46:11 -0600
committerMike Greiling <mike@pixelcog.com>2019-01-10 00:00:39 -0600
commit87c571f8a3e9af9de0d979dc26f9838bb0fc924d (patch)
tree696c6b5f9e6d77996608acdd6f952826e2c52e8f /app
parent2cbc475e5327a860032414561916c7bd725685ac (diff)
downloadgitlab-ce-87c571f8a3e9af9de0d979dc26f9838bb0fc924d.tar.gz
Addressing feedback from most recent reviews.
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/lib/utils/common_utils.js8
-rw-r--r--app/assets/javascripts/lib/utils/url_utility.js6
-rw-r--r--app/assets/javascripts/pages/sessions/new/preserve_url_fragment.js4
3 files changed, 4 insertions, 14 deletions
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js
index afdca012127..fc34d243dd7 100644
--- a/app/assets/javascripts/lib/utils/common_utils.js
+++ b/app/assets/javascripts/lib/utils/common_utils.js
@@ -4,14 +4,6 @@ import { getLocationHash } from './url_utility';
import { convertToCamelCase } from './text_utility';
import { isObject } from './type_utility';
-/**
- * Simply returns `window.location`. This function exists to provide a means to spy
- * `window.location` in unit tests.
- *
- * @returns {Location | string | any} The browser's `window.location`
- */
-export const windowLocation = () => window.location;
-
export const getPagePath = (index = 0) => {
const page = $('body').attr('data-page') || '';
diff --git a/app/assets/javascripts/lib/utils/url_utility.js b/app/assets/javascripts/lib/utils/url_utility.js
index 61f53a632b8..4ba84589705 100644
--- a/app/assets/javascripts/lib/utils/url_utility.js
+++ b/app/assets/javascripts/lib/utils/url_utility.js
@@ -1,5 +1,3 @@
-import { windowLocation } from './common_utils';
-
// Returns an array containing the value(s) of the
// of the key passed as an argument
export function getParameterValues(sParam) {
@@ -53,11 +51,11 @@ export function mergeUrlParams(params, url) {
* @param {string} [url=windowLocation().href] - url from which the query param will be removed
* @returns {string} A copy of the original url but without the query param
*/
-export function removeParams(params, url = windowLocation().href) {
+export function removeParams(params, url = window.location.href) {
const [rootAndQuery, fragment] = url.split('#');
const [root, query] = rootAndQuery.split('?');
- if (query === undefined) {
+ if (!query) {
return url;
}
diff --git a/app/assets/javascripts/pages/sessions/new/preserve_url_fragment.js b/app/assets/javascripts/pages/sessions/new/preserve_url_fragment.js
index 56ea39f1259..e617fecaa0f 100644
--- a/app/assets/javascripts/pages/sessions/new/preserve_url_fragment.js
+++ b/app/assets/javascripts/pages/sessions/new/preserve_url_fragment.js
@@ -6,8 +6,8 @@ import { mergeUrlParams, setUrlFragment } from '~/lib/utils/url_utility';
*
* @param fragment {string} - url fragment to be preserved
*/
-export default function preserveUrlFragment(fragment) {
- if (fragment && fragment !== '') {
+export default function preserveUrlFragment(fragment = '') {
+ if (fragment) {
const normalFragment = fragment.replace(/^#/, '');
// Append the fragment to all sign-in/sign-up form actions so it is preserved when the user is