@@ -60,7 +60,10 @@ export default class TemplateRenderer {
6060 // extra functionality with client manifest
6161 if ( options . clientManifest ) {
6262 const clientManifest = this . clientManifest = options . clientManifest
63- this . publicPath = clientManifest . publicPath
63+ // ensure publicPath ends with /
64+ this . publicPath = clientManifest . publicPath === ''
65+ ? ''
66+ : clientManifest . publicPath . replace ( / ( [ ^ \/ ] ) $ / , '$1/' )
6467 // preload/prefetch directives
6568 this . preloadFiles = ( clientManifest . initial || [ ] ) . map ( normalizeFile )
6669 this . prefetchFiles = ( clientManifest . async || [ ] ) . map ( normalizeFile )
@@ -114,7 +117,7 @@ export default class TemplateRenderer {
114117 return (
115118 // render links for css files
116119 ( cssFiles . length
117- ? cssFiles . map ( ( { file } ) => `<link rel="stylesheet" href="${ this . getPublicPath ( file ) } ">` ) . join ( '' )
120+ ? cssFiles . map ( ( { file } ) => `<link rel="stylesheet" href="${ this . publicPath } ${ file } ">` ) . join ( '' )
118121 : '' ) +
119122 // context.styles is a getter exposed by vue-style-loader which contains
120123 // the inline component styles collected during SSR
@@ -153,7 +156,7 @@ export default class TemplateRenderer {
153156 extra = ` type="font/${ extension } " crossorigin`
154157 }
155158 return `<link rel="preload" href="${
156- this . getPublicPath ( file )
159+ this . publicPath } ${ file
157160 } "${
158161 asType !== '' ? ` as="${ asType } "` : ''
159162 } ${
@@ -179,7 +182,7 @@ export default class TemplateRenderer {
179182 if ( alreadyRendered ( file ) ) {
180183 return ''
181184 }
182- return `<link rel="prefetch" href="${ this . getPublicPath ( file ) } ">`
185+ return `<link rel="prefetch" href="${ this . publicPath } ${ file } ">`
183186 } ) . join ( '' )
184187 } else {
185188 return ''
@@ -206,7 +209,7 @@ export default class TemplateRenderer {
206209 const async = ( this . getUsedAsyncFiles ( context ) || [ ] ) . filter ( ( { file } ) => isJS ( file ) )
207210 const needed = [ initial [ 0 ] ] . concat ( async || [ ] , initial . slice ( 1 ) )
208211 return needed . map ( ( { file } ) => {
209- return `<script src="${ this . getPublicPath ( file ) } " defer></script>`
212+ return `<script src="${ this . publicPath } ${ file } " defer></script>`
210213 } ) . join ( '' )
211214 } else {
212215 return ''
@@ -228,10 +231,6 @@ export default class TemplateRenderer {
228231 }
229232 return new TemplateStream ( this , this . parsedTemplate , context || { } )
230233 }
231-
232- getPublicPath ( file : string ) {
233- return path . posix . join ( this . publicPath , file )
234- }
235234}
236235
237236function normalizeFile ( file : string ) : Resource {
0 commit comments