JS: Introduce Icinga.Utils.addUrlFlag()
This commit is contained in:
parent
8da37e5ca2
commit
4d02d8f6d6
|
@ -210,6 +210,30 @@
|
|||
return params;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add the specified flag to the given URL
|
||||
*
|
||||
* @param {string} url
|
||||
* @param {string} flag
|
||||
*
|
||||
* @returns {string}
|
||||
*/
|
||||
addUrlFlag: function (url, flag) {
|
||||
var pos = url.lastIndexOf('#');
|
||||
|
||||
if (url.indexOf('?') !== -1) {
|
||||
flag = '&' + flag;
|
||||
} else {
|
||||
flag = '?' + flag;
|
||||
}
|
||||
|
||||
if (pos === -1) {
|
||||
return url + flag;
|
||||
}
|
||||
|
||||
return url.slice(0, pos) + flag + url.slice(pos);
|
||||
},
|
||||
|
||||
/**
|
||||
* Check whether two HTMLElements overlap
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue