Skip to content

Commit 2ef3249

Browse files
committed
fixes windows path delimiter issue
1 parent 7409065 commit 2ef3249

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/webpack/index.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
'use strict';
22

3+
const replacePathDelimiter = (str) => str.replace(/\\|\//g, "/")
4+
35
// Based on the NormalModuleReplacementPlugin plugin.
46
class NativeScriptHTTPPlugin {
57
constructor() {
@@ -38,20 +40,20 @@ class NativeScriptHTTPPlugin {
3840

3941
// Replace the relative http-request import from core image-cache (for iOS).
4042
if (this.replaceHTTP && result.request === "../../http/http-request") {
41-
if (result.context.endsWith("@nativescript/core/ui/image-cache")) {
43+
if (replacePathDelimiter(result.context).endsWith("@nativescript/core/ui/image-cache")) {
4244
result.request = "../../../../@klippa/nativescript-http";
4345
}
44-
if (result.context.endsWith("tns-core-modules/ui/image-cache")) {
46+
if (replacePathDelimiter(result.context).endsWith("tns-core-modules/ui/image-cache")) {
4547
result.request = "../../../@klippa/nativescript-http";
4648
}
4749
}
4850

4951
// Replace the relative image-cache import from core ui.
5052
if (this.replaceImageCache && result.request === "./image-cache") {
51-
if (result.context.endsWith("@nativescript/core/ui")) {
53+
if (replacePathDelimiter(result.context).endsWith("@nativescript/core/ui")) {
5254
result.request = "../../../@klippa/nativescript-http/image-cache";
5355
}
54-
if (result.context.endsWith("tns-core-modules/ui")) {
56+
if (replacePathDelimiter(result.context).endsWith("tns-core-modules/ui")) {
5557
result.request = "../../@klippa/nativescript-http/image-cache";
5658
}
5759
}
@@ -65,7 +67,7 @@ class NativeScriptHTTPPlugin {
6567
if (this.replaceImageCache && (result.request === "@nativescript/core/ui/image-cache" || result.request === "tns-core-modules/image-cache")) {
6668
// Make sure we don't ruin our own import.
6769
// We import image-cache for iOS because that implementation is fine.
68-
if (!result.context.endsWith("src/image-cache") && !(result.context.endsWith("@klippa/nativescript-http/image-cache"))) {
70+
if (!replacePathDelimiter(result.context).endsWith("src/image-cache") && !(replacePathDelimiter(result.context).endsWith("@klippa/nativescript-http/image-cache"))) {
6971
result.request = "@klippa/nativescript-http/image-cache";
7072
}
7173
}

0 commit comments

Comments
 (0)