Skip to content

Commit 186db54

Browse files
authored
Merge pull request #52 from mayerlench/fixes-windows-path-delimiter
fixes windows path delimiter issue
2 parents e7957c1 + d09028a commit 186db54

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/webpack/index.js

Lines changed: 9 additions & 7 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() {
@@ -28,30 +30,30 @@ class NativeScriptHTTPPlugin {
2830
if (resourceRegExp.test(result.request)) {
2931
// Replace the relative http-request import from core http.
3032
if (this.replaceHTTP && result.request === "./http-request") {
31-
if (result.context.endsWith("@nativescript/core/http")) {
33+
if (replacePathDelimiter(result.context).endsWith("@nativescript/core/http")) {
3234
result.request = "../../../@klippa/nativescript-http";
3335
}
34-
if (result.context.endsWith("tns-core-modules/http")) {
36+
if (replacePathDelimiter(result.context).endsWith("tns-core-modules/http")) {
3537
result.request = "../../@klippa/nativescript-http";
3638
}
3739
}
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)