Skip to content

Commit 07b7117

Browse files
committed
Support single-slashed absolute paths in FileSystemXHR
1 parent 2967ea6 commit 07b7117

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/nativescript-angular/xhr.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {XHR} from "@angular/compiler/src/xhr";
44
export class FileSystemXHR extends XHR {
55
resolve(url: string, baseUrl: string): string {
66
//Angular assembles absolute URL's and prefixes them with //
7-
if (url.indexOf("//") !== 0) {
7+
if (url.indexOf("/") !== 0) {
88
//Resolve relative URL's based on the app root.
99
return path.join(baseUrl, url);
1010
} else {

tests/app/tests/xhr-paths.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ describe("XHR name resolution", () => {
88
assert.strictEqual("/app/dir/mydir/mycomponent.html", xhr.resolve("mydir/mycomponent.html", "/app/dir"))
99
});
1010

11-
it("resolves absolute paths as is", () => {
11+
it("resolves double-slashed absolute paths as is", () => {
1212
const xhr = new FileSystemXHR();
1313
assert.strictEqual("//app/mydir/mycomponent.html", xhr.resolve("//app/mydir/mycomponent.html", "/app/dir"))
1414
});
15+
16+
it("resolves single-slashed absolute paths as is", () => {
17+
const xhr = new FileSystemXHR();
18+
assert.strictEqual("/data/data/app/mydir/mycomponent.html", xhr.resolve("/data/data/app/mydir/mycomponent.html", "/app/dir"))
19+
});
1520
})

0 commit comments

Comments
 (0)