@@ -133,6 +133,40 @@ module.exports = ({
133133 } )
134134 compiler . outputFileSystem = fs
135135 } )
136+
137+ it ( 'should gracefully handle missing publicPath separators' , function ( done ) {
138+ const fs = new MemoryFileSystem ( )
139+ const compiler = webpack ( {
140+ entry : {
141+ js : path . join ( __dirname , 'fixtures' , 'file.js' )
142+ } ,
143+ output : {
144+ path : OUTPUT_DIR ,
145+ filename : 'bundle.js' ,
146+ chunkFilename : 'chunk.[chunkhash].js' ,
147+ publicPath : '/a'
148+ } ,
149+ plugins : [
150+ new HtmlWebpackPlugin ( ) ,
151+ new PreloadPlugin ( )
152+ ]
153+ } , function ( err , result ) {
154+ expect ( err ) . toBeFalsy ( err )
155+ expect ( result . compilation . errors . length ) . toBe ( 0 ,
156+ result . compilation . errors . join ( '\n=========\n' ) )
157+
158+ const html = fs . readFileSync ( path . join ( OUTPUT_DIR , 'index.html' ) , 'utf-8' )
159+ const dom = new JSDOM ( html )
160+
161+ const links = dom . window . document . head . querySelectorAll ( 'link' )
162+ expect ( links . length ) . toBe ( 1 )
163+ expect ( links [ 0 ] . getAttribute ( 'rel' ) ) . toBe ( 'preload' )
164+ expect ( links [ 0 ] . getAttribute ( 'href' ) ) . toMatch ( new RegExp ( '^/a/chunk\\.' ) )
165+
166+ done ( )
167+ } )
168+ compiler . outputFileSystem = fs
169+ } )
136170 } )
137171
138172 describe ( `${ descriptionPrefix } When passed non-async chunks, it` , function ( ) {
0 commit comments