Added path normalization on Windows, along with some tests

This commit is contained in:
Alexander Cerutti
2021-12-28 01:05:14 +01:00
parent 2923eb4d66
commit d0b0f8537f
2 changed files with 20 additions and 2 deletions

View File

@@ -1,4 +1,5 @@
import { Stream } from "stream";
import path from "path";
import FieldsArray from "./FieldsArray";
import Bundle, { filesSymbol } from "./Bundle";
import getModelFolderContents from "./getModelFolderContents";
@@ -435,6 +436,13 @@ export default class PKPass extends Bundle {
return super.addBuffer(pathName, buffer);
}
/**
* Converting Windows path to Unix path
* @example de.lproj\\icon.png => de.lproj/icon.png
*/
const normalizedPathName = pathName.replace(path.sep, "/");
/**
* If a new pass.strings file is added, we want to
* prevent it from being merged and, instead, save
@@ -446,7 +454,7 @@ export default class PKPass extends Bundle {
let match: RegExpMatchArray | null;
if ((match = pathName.match(translationsFileRegexp))) {
if ((match = normalizedPathName.match(translationsFileRegexp))) {
const [, lang] = match;
const parsedTranslations = Strings.parse(buffer).translations;
@@ -460,7 +468,7 @@ export default class PKPass extends Bundle {
return;
}
return super.addBuffer(pathName, buffer);
return super.addBuffer(normalizedPathName, buffer);
}
/**