Skip to content

Commit

Permalink
SourceFileTest.testSourceFileResolvesZipEntries failes for Windows go…
Browse files Browse the repository at this point in the history
…ogle#3206

And fixes parts of "Support the workflow under Windows. google#9" (google/j2cl#9) from j2cl
  • Loading branch information
lgemeinhardt authored Jan 23, 2019
1 parent 877e304 commit bbb67d5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/com/google/javascript/jscomp/SourceFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

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

private static boolean isZipEntry(String path) {
return path.contains(".zip!/") && (path.endsWith(".js") || path.endsWith(".js.map"));
return path.contains(".zip!" + File.separatorChar) && (path.endsWith(".js") || path.endsWith(".js.map"));
}

@GwtIncompatible("java.io.File")
private static SourceFile fromZipEntry(String zipURL, Charset inputCharset) {
checkArgument(isZipEntry(zipURL));
String[] components = zipURL.split(BANG_SLASH);
String[] components = zipURL.split(Pattern.quote(BANG_SLASH.replace('/', File.separatorChar)));
try {
String zipPath = components[0];
String relativePath = components[1];
Expand All @@ -378,7 +379,7 @@ private static SourceFile fromZipEntry(String zipURL, Charset inputCharset) {
public static SourceFile fromZipEntry(
String originalZipPath, String absoluteZipPath, String entryPath, Charset inputCharset)
throws MalformedURLException {
String zipEntryPath = JAR_URL_PREFIX + absoluteZipPath + BANG_SLASH + entryPath;
String zipEntryPath = JAR_URL_PREFIX + absoluteZipPath + BANG_SLASH + entryPath.replace(File.pathSeparatorChar, '/');
URL zipEntryUrl = new URL(zipEntryPath);

return builder()
Expand Down

0 comments on commit bbb67d5

Please sign in to comment.