mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* moved datasource related functions to panel sub-class * expand panel template vars for url * added keybindings for x -> Explore * url encoding for explore state
18 lines
714 B
TypeScript
18 lines
714 B
TypeScript
import config from 'app/core/config';
|
|
|
|
// Slash encoding for angular location provider, see https://github.com/angular/angular.js/issues/10479
|
|
const SLASH = '<SLASH>';
|
|
export const decodePathComponent = (pc: string) => decodeURIComponent(pc).replace(new RegExp(SLASH, 'g'), '/');
|
|
export const encodePathComponent = (pc: string) => encodeURIComponent(pc.replace(/\//g, SLASH));
|
|
|
|
export const stripBaseFromUrl = url => {
|
|
const appSubUrl = config.appSubUrl;
|
|
const stripExtraChars = appSubUrl.endsWith('/') ? 1 : 0;
|
|
const urlWithoutBase =
|
|
url.length > 0 && url.indexOf(appSubUrl) === 0 ? url.slice(appSubUrl.length - stripExtraChars) : url;
|
|
|
|
return urlWithoutBase;
|
|
};
|
|
|
|
export default { stripBaseFromUrl };
|