Skip to content

Commit f7b2c14

Browse files
committed
Iterate backwards when doing replacements.
1 parent 2479d8c commit f7b2c14

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

webpack/set-webpack-public-path-plugin/src/SetPublicPathPlugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ export class SetPublicPathPlugin extends SetPublicPathPluginBase {
192192
const newAsset: webpack.sources.ReplaceSource = new thisWebpack.sources.ReplaceSource(asset);
193193
const sourceString: string = asset.source().toString();
194194
for (
195-
let index: number = sourceString.indexOf(ASSET_NAME_TOKEN);
195+
let index: number = sourceString.lastIndexOf(ASSET_NAME_TOKEN);
196196
index >= 0;
197-
index = sourceString.indexOf(ASSET_NAME_TOKEN, index + 1)
197+
index = sourceString.lastIndexOf(ASSET_NAME_TOKEN, index - 1)
198198
) {
199199
newAsset.replace(index, index + ASSET_NAME_TOKEN.length - 1, escapedAssetFilename);
200200
}

0 commit comments

Comments
 (0)