summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/lib/utils
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2018-01-12 19:43:38 +0800
committerLin Jen-Shin <godfat@godfat.org>2018-01-12 19:43:38 +0800
commitcfd75101d19db3235b64b05d7a58616db40f22c6 (patch)
tree6eef1dd8bd6a1ddc8f69ffdf35bf2f9b6771c30c /app/assets/javascripts/lib/utils
parentf4bd9c0b5e1eafe6de855d73bfb606909229f382 (diff)
parentf9579df8617add53424f57c0feedfa601a77e923 (diff)
downloadgitlab-ce-cfd75101d19db3235b64b05d7a58616db40f22c6.tar.gz
Merge remote-tracking branch 'upstream/master' into 1819-override-ce
* upstream/master: (621 commits) Add a note about GitLab QA page objects validator to docs Refactor dispatcher projects blame and blob path Update export message to mention we can download the file from the UI Fix Ctrl+Enter keyboard shortcut saving comment/note edit fix case where tooltip messes up :last-child selector Add reason to keep postgresql 9.2 for CI Remove warning noise in ProjectImportOptions Add changelog entry Add RedirectRoute factory Update Ingress extra cost note to be more generic Fix Rubocop offense Refactor dispatcher project branches path Revert "Revert "Fix Route validation for unchanged path"" Document that we need rsync for backing up Docs: move article "Laravel and Envoy w/ CI/CD" Recommend against the use of EFS Adds Rubocop rule for line break around conditionals Update CHANGELOG.md for 10.1.6 Filter out build traces from logged parameters Refactored project:n* imports in dispatcher.js ...
Diffstat (limited to 'app/assets/javascripts/lib/utils')
-rw-r--r--app/assets/javascripts/lib/utils/axios_utils.js2
-rw-r--r--app/assets/javascripts/lib/utils/common_utils.js2
-rw-r--r--app/assets/javascripts/lib/utils/text_utility.js9
-rw-r--r--app/assets/javascripts/lib/utils/url_utility.js2
4 files changed, 13 insertions, 2 deletions
diff --git a/app/assets/javascripts/lib/utils/axios_utils.js b/app/assets/javascripts/lib/utils/axios_utils.js
index 7aeeca3b283..8aff0556011 100644
--- a/app/assets/javascripts/lib/utils/axios_utils.js
+++ b/app/assets/javascripts/lib/utils/axios_utils.js
@@ -2,6 +2,8 @@ import axios from 'axios';
import csrf from './csrf';
axios.defaults.headers.common[csrf.headerKey] = csrf.token;
+// Used by Rails to check if it is a valid XHR request
+axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
// Maintain a global counter for active requests
// see: spec/support/wait_for_requests.rb
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js
index b5328c77b25..03918762842 100644
--- a/app/assets/javascripts/lib/utils/common_utils.js
+++ b/app/assets/javascripts/lib/utils/common_utils.js
@@ -232,7 +232,7 @@ export const nodeMatchesSelector = (node, selector) => {
export const normalizeHeaders = (headers) => {
const upperCaseHeaders = {};
- Object.keys(headers).forEach((e) => {
+ Object.keys(headers || {}).forEach((e) => {
upperCaseHeaders[e.toUpperCase()] = headers[e];
});
diff --git a/app/assets/javascripts/lib/utils/text_utility.js b/app/assets/javascripts/lib/utils/text_utility.js
index 9280b7f150c..cb6e06ea584 100644
--- a/app/assets/javascripts/lib/utils/text_utility.js
+++ b/app/assets/javascripts/lib/utils/text_utility.js
@@ -64,3 +64,12 @@ export const truncate = (string, maxLength) => `${string.substr(0, (maxLength -
export function capitalizeFirstCharacter(text) {
return `${text[0].toUpperCase()}${text.slice(1)}`;
}
+
+/**
+ * Replaces all html tags from a string with the given replacement.
+ *
+ * @param {String} string
+ * @param {*} replace
+ * @returns {String}
+ */
+export const stripeHtml = (string, replace = '') => string.replace(/<[^>]*>/g, replace);
diff --git a/app/assets/javascripts/lib/utils/url_utility.js b/app/assets/javascripts/lib/utils/url_utility.js
index f1ee9c8f2e5..a266bb6771f 100644
--- a/app/assets/javascripts/lib/utils/url_utility.js
+++ b/app/assets/javascripts/lib/utils/url_utility.js
@@ -18,7 +18,7 @@ export function getParameterValues(sParam) {
// @param {String} url
export function mergeUrlParams(params, url) {
let newUrl = Object.keys(params).reduce((acc, paramName) => {
- const paramValue = params[paramName];
+ const paramValue = encodeURIComponent(params[paramName]);
const pattern = new RegExp(`\\b(${paramName}=).*?(&|$)`);
if (paramValue === null) {