mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Assure base url when single stat, panel and data links are built * Update public/app/features/dashboard/dashgrid/PanelHeader/PanelHeaderCorner.tsx * Update public/app/features/panel/panellinks/link_srv.ts * Update public/app/features/panel/panellinks/link_srv.ts * Update public/app/features/panel/panellinks/link_srv.ts * Update public/app/features/panel/panellinks/link_srv.ts * Review updates * Remove unnecessary code
20 lines
582 B
TypeScript
20 lines
582 B
TypeScript
import { getConfig } from 'app/core/config';
|
|
|
|
export const stripBaseFromUrl = (url: string): string => {
|
|
const appSubUrl = getConfig().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 const assureBaseUrl = (url: string) => {
|
|
if (url.startsWith('/')) {
|
|
return `${getConfig().appSubUrl}${stripBaseFromUrl(url)}`;
|
|
}
|
|
return url;
|
|
};
|
|
|
|
export default { stripBaseFromUrl, assureBaseUrl };
|