Fix links for the menus in the view file page (#22795)
This commit is contained in:
parent
d5fa2e7510
commit
2c6cc0b8c9
4 changed files with 24 additions and 12 deletions
|
@ -134,9 +134,15 @@ export function convertImage(blob, mime) {
|
|||
});
|
||||
}
|
||||
|
||||
export function toAbsoluteUrl(relUrl) {
|
||||
if (relUrl.startsWith('http://') || relUrl.startsWith('https://')) {
|
||||
return relUrl;
|
||||
export function toAbsoluteUrl(url) {
|
||||
if (url.startsWith('http://') || url.startsWith('https://')) {
|
||||
return url;
|
||||
}
|
||||
return `${window.location.origin}${relUrl}`;
|
||||
if (url.startsWith('//')) {
|
||||
return `${window.location.protocol}${url}`; // it's also a somewhat absolute URL (with the current scheme)
|
||||
}
|
||||
if (url && !url.startsWith('/')) {
|
||||
throw new Error('unsupported url, it should either start with / or http(s)://');
|
||||
}
|
||||
return `${window.location.origin}${url}`;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue