mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
test(core): Add test to ensure Angular correctly detects paths when served from file system
This test makes sure that when Angular is served from Electron or just from the file system that the router works correctly.
(cherry picked from commit 70b252cac3)
This commit is contained in:
@@ -67,6 +67,28 @@ describe('dom adapter', () => {
|
||||
|
||||
expect(baseHref.endsWith('/base')).toBe(true);
|
||||
});
|
||||
|
||||
it('should resolve a local absolute base href when having a local file path', () => {
|
||||
const doc = getDOM().getDefaultDocument();
|
||||
|
||||
Object.defineProperty(doc, 'baseURI', {
|
||||
value: 'file:///C:/Users/Test/Somewhere(2)/',
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
const baseEl = getDOM().createElement('base');
|
||||
baseEl.setAttribute('href', 'base');
|
||||
const headEl = defaultDoc.head;
|
||||
headEl.appendChild(baseEl);
|
||||
|
||||
const baseHref = getDOM().getBaseHref(defaultDoc)!;
|
||||
|
||||
baseEl.remove();
|
||||
getDOM().resetBaseElement();
|
||||
delete (doc as any).baseURI;
|
||||
|
||||
expect(baseHref).toEqual('/C:/Users/Test/Somewhere(2)/base');
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user