mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
@@ -79,14 +79,9 @@ export function baseUrl(): string {
|
||||
|
||||
/**
|
||||
* Create an absolute href in the current content.
|
||||
* If it's the root URL, the trailing slash will be removed.
|
||||
*/
|
||||
export function absoluteHref(href: string, withHost: boolean = false): string {
|
||||
const base = withHost ? baseUrl() : basePath();
|
||||
if (href === '') {
|
||||
// Remove the trailing slash if it's the root URL
|
||||
return base.slice(0, -1);
|
||||
}
|
||||
return `${base}${href.startsWith('/') ? href.slice(1) : href}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user