@@ -29,6 +29,7 @@ import type {
2929 SidebarEntry ,
3030} from './routing/types' ;
3131import { localeToLang , localizedId , slugToPathname } from './slugs' ;
32+ import { isAbsoluteUrl } from './url' ;
3233import type { StarlightConfig } from './user-config' ;
3334
3435const DirKey = Symbol ( 'DirKey' ) ;
@@ -124,13 +125,10 @@ function groupFromAutogenerateConfig(
124125 } ;
125126}
126127
127- /** Check if a string starts with one of `http://` or `https://`. */
128- const isAbsolute = ( link : string ) => / ^ h t t p s ? : \/ \/ / . test ( link ) ;
129-
130128/** Create a link entry from a manual link item in user config. */
131129function linkFromSidebarLinkItem ( item : SidebarLinkItem , locale : string | undefined ) {
132130 let href = item . link ;
133- if ( ! isAbsolute ( href ) ) {
131+ if ( ! isAbsoluteUrl ( href ) ) {
134132 href = ensureLeadingSlash ( href ) ;
135133 // Inject current locale into link.
136134 if ( locale ) href = '/' + locale + href ;
@@ -186,7 +184,7 @@ function makeSidebarLink(
186184 badge ?: Badge ,
187185 attrs ?: LinkHTMLAttributes
188186) : SidebarLink {
189- if ( ! isAbsolute ( href ) ) {
187+ if ( ! isAbsoluteUrl ( href ) ) {
190188 href = formatPath ( href ) ;
191189 }
192190 return makeLink ( { label, href, badge, attrs } ) ;
0 commit comments