Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Eastwood <contact@ericeastwood.com>2017-09-20 23:35:49 +0300
committerEric Eastwood <contact@ericeastwood.com>2017-09-29 22:39:27 +0300
commit3265ccfc5a6a5c9a853956f84554f470286bb5ed (patch)
treefdcfb0fb8d50adf2c01e93bacd87dc3c07b6405d /app/assets/javascripts/lib/utils/url_utility.js
parentaec1586c05f30c1a81928b441cd63e422752e56c (diff)
Add external link FE for online artifacts
FE for https://gitlab.com/gitlab-org/gitlab-ce/issues/34102
Diffstat (limited to 'app/assets/javascripts/lib/utils/url_utility.js')
-rw-r--r--app/assets/javascripts/lib/utils/url_utility.js20
1 files changed, 18 insertions, 2 deletions
diff --git a/app/assets/javascripts/lib/utils/url_utility.js b/app/assets/javascripts/lib/utils/url_utility.js
index 3328ff9cc23..6512f7c8a94 100644
--- a/app/assets/javascripts/lib/utils/url_utility.js
+++ b/app/assets/javascripts/lib/utils/url_utility.js
@@ -1,4 +1,5 @@
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-var, no-param-reassign, no-cond-assign, one-var, one-var-declaration-per-line, no-void, guard-for-in, no-restricted-syntax, prefer-template, quotes, max-len */
+
var base;
var w = window;
if (w.gl == null) {
@@ -86,6 +87,21 @@ w.gl.utils.getLocationHash = function(url) {
w.gl.utils.refreshCurrentPage = () => gl.utils.visitUrl(document.location.href);
-w.gl.utils.visitUrl = (url) => {
- document.location.href = url;
+// eslint-disable-next-line import/prefer-default-export
+export function visitUrl(url, external = false) {
+ if (external) {
+ // Simulate `target="blank" ref="noopener noreferrer"`
+ // See https://mathiasbynens.github.io/rel-noopener/
+ const otherWindow = window.open();
+ otherWindow.opener = null;
+ otherWindow.location = url;
+ } else {
+ document.location.href = url;
+ }
+}
+
+window.gl = window.gl || {};
+window.gl.utils = {
+ ...(window.gl.utils || {}),
+ visitUrl,
};