File tree Expand file tree Collapse file tree
test/configCases/asset-modules/minimize-fragment-names Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2565,7 +2565,7 @@ const applyOptimizationDefaults = (
25652565 * @returns {RegExp } matcher for asset names with those extensions
25662566 */
25672567 const assetNameTest = ( extensions ) =>
2568- new RegExp ( `\\.(?:${ extensions . join ( "|" ) } )(?:[?#].*)?$` , "i" ) ;
2568+ new RegExp ( `^[^?#]* \\.(?:${ extensions . join ( "|" ) } )(?:[?#].*)?$` , "i" ) ;
25692569 if ( minifyJs && ! minifyCss && ! minifyHtml ) {
25702570 new TerserPlugin ( {
25712571 test : assetNameTest ( [ "[cm]?js" ] ) ,
Original file line number Diff line number Diff line change @@ -173,6 +173,6 @@ cssMinify.getEmbeddedTypes = () => [
173173 * @param {string } name asset filename
174174 * @returns {boolean } true for CSS assets
175175 */
176- cssMinify . filter = ( name ) => / \. c s s (?: [ ? # ] .* ) ? $ / i. test ( name ) ;
176+ cssMinify . filter = ( name ) => / ^ [ ^ ? # ] * \. c s s (?: [ ? # ] .* ) ? $ / i. test ( name ) ;
177177
178178module . exports = cssMinify ;
Original file line number Diff line number Diff line change @@ -252,6 +252,6 @@ htmlMinify.getEmbeddedTypes = () => {
252252 * @param {string } name asset filename
253253 * @returns {boolean } true for HTML assets
254254 */
255- htmlMinify . filter = ( name ) => / \. h t m l (?: [ ? # ] .* ) ? $ / i. test ( name ) ;
255+ htmlMinify . filter = ( name ) => / ^ [ ^ ? # ] * \. h t m l (?: [ ? # ] .* ) ? $ / i. test ( name ) ;
256256
257257module . exports = htmlMinify ;
Original file line number Diff line number Diff line change @@ -267,6 +267,6 @@ jsMinify.getTypes = () => ["javascript"];
267267 * @param {string } name asset filename
268268 * @returns {boolean } true for JavaScript assets
269269 */
270- jsMinify . filter = ( name ) => / \. [ c m ] ? j s (?: [ ? # ] .* ) ? $ / i. test ( name ) ;
270+ jsMinify . filter = ( name ) => / ^ [ ^ ? # ] * \. [ c m ] ? j s (?: [ ? # ] .* ) ? $ / i. test ( name ) ;
271271
272272module . exports = jsMinify ;
Original file line number Diff line number Diff line change 1+ not css {
Original file line number Diff line number Diff line change 1- const urls = [ new URL ( "./files/script.js#frag" , import . meta. url ) ] ;
1+ const urls = [
2+ new URL ( "./files/script.js#frag" , import . meta. url ) ,
3+ new URL ( "./files/data.txt#a.css" , import . meta. url )
4+ ] ;
25if ( CSS_AND_HTML ) {
36 urls . push (
47 new URL ( "./files/style.css#dark" , import . meta. url ) ,
@@ -8,8 +11,9 @@ if (CSS_AND_HTML) {
811
912it ( "should keep the fragment in the emitted asset URLs" , ( ) => {
1013 expect ( urls [ 0 ] . href ) . toMatch ( / s c r i p t \. j s # f r a g $ / ) ;
14+ expect ( urls [ 1 ] . href ) . toMatch ( / d a t a \. t x t # a \. c s s $ / ) ;
1115 if ( CSS_AND_HTML ) {
12- expect ( urls [ 1 ] . href ) . toMatch ( / s t y l e \. c s s # d a r k $ / ) ;
13- expect ( urls [ 2 ] . href ) . toMatch ( / p a g e \. h t m l # t o p $ / ) ;
16+ expect ( urls [ 2 ] . href ) . toMatch ( / s t y l e \. c s s # d a r k $ / ) ;
17+ expect ( urls [ 3 ] . href ) . toMatch ( / p a g e \. h t m l # t o p $ / ) ;
1418 }
1519} ) ;
Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ module.exports = {
2020 ) ;
2121 }
2222
23+ // The extension is read before the fragment, so `#a.css` claims nothing.
24+ expect ( read ( "1/data.txt" ) ) . toBe ( "not css {\n" ) ;
25+
2326 // Only the second build enables native CSS and HTML.
2427 expect ( read ( "1/style.css" ) ) . toBe ( ".fragment{color:red}" ) ;
2528 expect ( read ( "1/page.html" ) ) . toBe (
You can’t perform that action at this time.
0 commit comments