sourcemaps: ability to resolve sources relative to generated file

This commit is contained in:
Vladimir Krivosheev
2013-11-06 18:04:41 +01:00
parent 6c84d334a6
commit 4d9e68668c
2 changed files with 16 additions and 2 deletions
@@ -169,6 +169,9 @@ public final class UrlImpl implements Url {
return true;
}
if (!(o instanceof UrlImpl)) {
if (o instanceof LocalFileUrl && isInLocalFileSystem()) {
return o.getPath().equals(path);
}
return false;
}
@@ -120,12 +120,23 @@ public final class Urls {
// must not be used in NodeJS
public static Url newFromVirtualFile(@NotNull VirtualFile file) {
String path = file.getPath();
if (file.isInLocalFileSystem()) {
return new UrlImpl(file.getFileSystem().getProtocol(), null, path);
return new UrlImpl(file.getFileSystem().getProtocol(), null, file.getPath());
}
else {
return parseUrl(file.getUrl(), false);
}
}
public static boolean equalsIgnoreParameters(@NotNull Url url, @NotNull VirtualFile file) {
if (file.isInLocalFileSystem()) {
return url.isInLocalFileSystem() && url.getPath().equals(file.getPath());
}
else if (url.isInLocalFileSystem()) {
return false;
}
Url fileUrl = parseUrl(file.getUrl(), false);
return fileUrl != null && fileUrl.equalsIgnoreParameters(url);
}
}