Skip to content

Commit b97ae03

Browse files
committed
fix: .test is faster than .match regex
1 parent 316488b commit b97ae03

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/extractor/index.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ function layersWithLatestFileModifications(
228228
// if finding a deleted file - trimming to its original file name for excluding it from extractedLayers
229229
// + not adding this file
230230
if (isWhitedOutFile(filename)) {
231-
removedFilesToIgnore.add(filename.replace(/.wh./, ""));
231+
removedFilesToIgnore.add(filename.replace(/\.wh\./, ""));
232232
continue;
233233
}
234234
// not adding previously found to be whited out files to extractedLayers
@@ -248,8 +248,13 @@ function layersWithLatestFileModifications(
248248
return extractedLayers;
249249
}
250250

251+
/**
252+
* check if a file is 'whited out', which is shown by
253+
* prefixing the filename with a .wh.
254+
* https://www.madebymikal.com/interpreting-whiteout-files-in-docker-image-layers/
255+
*/
251256
export function isWhitedOutFile(filename: string) {
252-
return filename.match(/.wh./gm);
257+
return /\.wh\./.test(filename);
253258
}
254259

255260
function isBufferType(type: FileContent): type is Buffer {

0 commit comments

Comments
 (0)