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:
Vincent
2026-06-09 10:13:40 +02:00
committed by Jessica Janiuk
parent 9d8aa3a829
commit edcb45bd91
@@ -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');
});
});
}
});