This repository was archived by the owner on Jan 16, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +9
-11
lines changed
Expand file tree Collapse file tree 4 files changed +9
-11
lines changed Original file line number Diff line number Diff line change 1- jest . requireActual ( 'babel/polyfill' ) ;
1+ require . requireActual ( 'babel/polyfill' ) ;
Original file line number Diff line number Diff line change @@ -7,13 +7,14 @@ import { configure } from 'enzyme';
77import Adapter from 'enzyme-adapter-react-16' ;
88import { GlobalWithFetchMock } from 'jest-fetch-mock' ;
99
10+ // @ts -ignore : Only a void function can be called with the 'new' keyword
1011configure ( { adapter : new Adapter ( ) } ) ;
1112
1213// @ts -ignore : Property '__APP_VERSION__' does not exist on type 'Global'.
1314global . __APP_VERSION__ = '1.0.0' ;
1415// @ts -ignore : Property '__VERDACCIO_BASENAME_UI_OPTIONS' does not exist on type 'Global'.
15- global . __VERDACCIO_BASENAME_UI_OPTIONS = { base : 'http://localhost' } ;
16- // @ts -ignore : Property 'VERDACCIO_API_URL' does not exist on type 'Global'.
16+ global . __VERDACCIO_BASENAME_UI_OPTIONS = { } ;
17+
1718global . VERDACCIO_API_URL = 'https://verdaccio.tld' ;
1819
1920const customGlobal : GlobalWithFetchMock = global as GlobalWithFetchMock ;
Original file line number Diff line number Diff line change @@ -17,18 +17,14 @@ describe('utils', () => {
1717 expect ( isEmail ( '' ) ) . toBeFalsy ( ) ;
1818 } ) ;
1919
20- test ( 'getRegistryURL() - should not change when location change' , ( ) => {
21- expect ( getRegistryURL ( ) ) . toBe ( 'http://localhost' ) ;
20+ test ( 'getRegistryURL() - should keep slash if location is a sub directory' , ( ) => {
2221 history . pushState ( { } , 'page title' , '/-/web/detail' ) ;
23- expect ( getRegistryURL ( ) ) . toBe ( 'http://localhost' ) ;
22+ expect ( getRegistryURL ( ) ) . toBe ( 'http://localhost/-/web/detail ' ) ;
2423 history . pushState ( { } , 'page title' , '/' ) ;
2524 } ) ;
2625
27- test ( 'getRegistryURL() - should change when UI options change ' , ( ) => {
26+ test ( 'getRegistryURL() - should not add slash if location is not a sub directory ' , ( ) => {
2827 expect ( getRegistryURL ( ) ) . toBe ( 'http://localhost' ) ;
29- window . __VERDACCIO_BASENAME_UI_OPTIONS . base = 'http://localhost/test' ;
30- expect ( getRegistryURL ( ) ) . toBe ( 'http://localhost/test' ) ;
31- window . __VERDACCIO_BASENAME_UI_OPTIONS . base = 'http://localhost' ;
3228 } ) ;
3329 } ) ;
3430
Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ export function isEmail(email: string): boolean {
1515}
1616
1717export function getRegistryURL ( ) : string {
18- return window . __VERDACCIO_BASENAME_UI_OPTIONS . base ;
18+ // Don't add slash if it's not a sub directory
19+ return `${ location . origin } ${ location . pathname === '/' ? '' : location . pathname } ` ;
1920}
2021
2122export function extractFileName ( url : string ) : string {
You can’t perform that action at this time.
0 commit comments