Skip to content

Commit 0af946b

Browse files
committed
SourceFileTest.testSourceFileResolvesZipEntries failes for Windows #3206
And fixes parts of "Support the workflow under Windows. #9" (google/j2cl#9) from j2cl
1 parent 877e304 commit 0af946b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/com/google/javascript/jscomp/SourceFile.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import java.util.Arrays;
4747
import java.util.Enumeration;
4848
import java.util.List;
49+
import java.util.regex.Pattern;
4950
import java.util.zip.ZipEntry;
5051
import java.util.zip.ZipFile;
5152

@@ -358,13 +359,13 @@ public static List<SourceFile> fromZipFile(String zipName, Charset inputCharset)
358359
private static final String JAR_URL_PREFIX = "jar:file:";
359360

360361
private static boolean isZipEntry(String path) {
361-
return path.contains(".zip!/") && (path.endsWith(".js") || path.endsWith(".js.map"));
362+
return path.contains(".zip!" + File.separator) && (path.endsWith(".js") || path.endsWith(".js.map"));
362363
}
363364

364365
@GwtIncompatible("java.io.File")
365366
private static SourceFile fromZipEntry(String zipURL, Charset inputCharset) {
366367
checkArgument(isZipEntry(zipURL));
367-
String[] components = zipURL.split(BANG_SLASH);
368+
String[] components = zipURL.split(Pattern.quote(BANG_SLASH.replace("/", File.separator)));
368369
try {
369370
String zipPath = components[0];
370371
String relativePath = components[1];
@@ -378,7 +379,7 @@ private static SourceFile fromZipEntry(String zipURL, Charset inputCharset) {
378379
public static SourceFile fromZipEntry(
379380
String originalZipPath, String absoluteZipPath, String entryPath, Charset inputCharset)
380381
throws MalformedURLException {
381-
String zipEntryPath = JAR_URL_PREFIX + absoluteZipPath + BANG_SLASH + entryPath;
382+
String zipEntryPath = JAR_URL_PREFIX + absoluteZipPath + BANG_SLASH + entryPath.replace(File.pathSeparator, "/");
382383
URL zipEntryUrl = new URL(zipEntryPath);
383384

384385
return builder()

0 commit comments

Comments
 (0)