File tree Expand file tree Collapse file tree 2 files changed +19
-4
lines changed
Expand file tree Collapse file tree 2 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -57,12 +57,25 @@ describe('Web root handling', () => {
5757 expect ( getBaseUrl ( ) ) . toBe ( `${ window . location . origin } /nextcloud` )
5858 } )
5959
60- // TODO: This seems to be wrong, would expect `/nextcloud`
60+ test ( 'with implicit empty web root' , ( ) => {
61+ window . _oc_webroot = undefined
62+ window . location . pathname = '/'
63+ expect ( getRootUrl ( ) ) . toBe ( '/' )
64+ expect ( getBaseUrl ( ) ) . toBe ( `${ window . location . origin } /` )
65+ } )
66+
6167 test ( 'with implicit web root and path rename' , ( ) => {
68+ window . _oc_webroot = undefined
69+ window . location . pathname = '/nextcloud'
70+ expect ( getRootUrl ( ) ) . toBe ( '/nextcloud' )
71+ expect ( getBaseUrl ( ) ) . toBe ( `${ window . location . origin } /nextcloud` )
72+ } )
73+
74+ test ( 'with implicit web root on route with path rename' , ( ) => {
6275 window . _oc_webroot = undefined
6376 window . location . pathname = '/nextcloud/apps/files'
64- expect ( getRootUrl ( ) ) . toBe ( '/nextcloud/apps ' )
65- expect ( getBaseUrl ( ) ) . toBe ( `${ window . location . origin } /nextcloud/apps ` )
77+ expect ( getRootUrl ( ) ) . toBe ( '/nextcloud' )
78+ expect ( getBaseUrl ( ) ) . toBe ( `${ window . location . origin } /nextcloud` )
6679 } )
6780} )
6881
Original file line number Diff line number Diff line change @@ -227,7 +227,9 @@ export function getRootUrl(): string {
227227 if ( pos !== - 1 ) {
228228 webroot = webroot . slice ( 0 , pos )
229229 } else {
230- webroot = webroot . slice ( 0 , webroot . lastIndexOf ( '/' ) )
230+ const index = webroot . indexOf ( '/' , 1 )
231+ // Make sure to not cut end of path if there is just the webroot like `/nextcloud`
232+ webroot = webroot . slice ( 0 , index > 0 ? index : undefined )
231233 }
232234 }
233235 return webroot
You can’t perform that action at this time.
0 commit comments