Login: convert scheme relative URL to path (#80220)

* Login: convert scheme relative URL to path

* linting
This commit is contained in:
Kristian Bremberg
2024-01-10 11:31:35 +02:00
committed by GitHub
parent 282a3f9a66
commit 2d6ad9f7c5
@@ -8,7 +8,12 @@ import { useStyles2 } from '@grafana/ui';
export function SignInLink() {
const location = useLocation();
const styles = useStyles2(getStyles);
const loginUrl = textUtil.sanitizeUrl(locationUtil.getUrlForPartial(location, { forceLogin: 'true' }));
let loginUrl = textUtil.sanitizeUrl(locationUtil.getUrlForPartial(location, { forceLogin: 'true' }));
// Fix for loginUrl starting with "//" which is a scheme relative URL
if (loginUrl.startsWith('//')) {
loginUrl = loginUrl.replace(/\/+/g, '/');
}
return (
<a className={styles.link} href={loginUrl} target="_self">