File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
packages-integrations/inspector/src Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -115,8 +115,15 @@ export default function UnocssInspector(ctx: UnocssPluginContext): Plugin {
115115 server . printUrls = ( ) => {
116116 _printUrls ( )
117117 for ( const localUrl of server . resolvedUrls ?. local ?? [ ] ) {
118- const url = server . config . base ? localUrl . replace ( server . config . base , '' ) : localUrl
119- const inspectorUrl = url . endsWith ( '/' ) ? `${ url } ${ baseUrl } /` : `${ url } /${ baseUrl } /`
118+ // server.config.base will be normalized with leading and trailing slashes,
119+ // but localUrl might not have a trailing slash
120+ const appUrl = localUrl . endsWith ( '/' ) ? localUrl : `${ localUrl } /`
121+ // remove the base path from appUrl if possible
122+ const serverUrl = server . config . base && appUrl . endsWith ( server . config . base )
123+ ? appUrl . slice ( 0 , - server . config . base . length )
124+ : appUrl . slice ( 0 , - 1 ) // remove the trailing slash
125+ // we removed the trailing slash from serverUrl when removing the base, add it back
126+ const inspectorUrl = `${ serverUrl } /${ baseUrl } /`
120127 // eslint-disable-next-line no-console
121128 console . log ( ` ${ green ( '➜' ) } ${ bold ( 'UnoCSS Inspector' ) } : ${ colorUrl ( `${ inspectorUrl } ` ) } ` )
122129 }
You can’t perform that action at this time.
0 commit comments