fix: generate correct registry URL (#413)

* Revert "Revert "fix(#300): correctly reference registry url from options" (#311)"

This reverts commit d955268c25.

* fix: generate full URL from path
This commit is contained in:
Daniel Ruf
2020-01-09 06:12:50 +01:00
committed by Juan Picado @jotadeveloper
parent 3fd0154da3
commit 6b322ad553
5 changed files with 12 additions and 10 deletions

View File

@@ -17,14 +17,18 @@ describe('utils', () => {
expect(isEmail('')).toBeFalsy();
});
test('getRegistryURL() - should keep slash if location is a sub directory', () => {
test('getRegistryURL() - should not change when location change', () => {
expect(getRegistryURL()).toBe('http://localhost');
history.pushState({}, 'page title', '/-/web/detail');
expect(getRegistryURL()).toBe('http://localhost/-/web/detail');
expect(getRegistryURL()).toBe('http://localhost');
history.pushState({}, 'page title', '/');
});
test('getRegistryURL() - should not add slash if location is not a sub directory', () => {
test('getRegistryURL() - should change when UI options change', () => {
expect(getRegistryURL()).toBe('http://localhost');
window.__VERDACCIO_BASENAME_UI_OPTIONS.base = 'http://localhost/test';
expect(getRegistryURL()).toBe('http://localhost/test');
window.__VERDACCIO_BASENAME_UI_OPTIONS.base = 'http://localhost';
});
});