-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5704 from nextcloud-libraries/backport/5703/next
[next] fix(richText): do not handle relative links without leading slash as router links
- Loading branch information
Showing
2 changed files
with
57 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,7 +108,7 @@ describe('autoLink', () => { | |
}) | ||
}) | ||
|
||
it('should not get route from relative link with base /nextcloud/index.php/apps/test/foo', () => { | ||
it('should not get route from relative link with base in the link /nextcloud/index.php/apps/test/foo', () => { | ||
getBaseUrl.mockReturnValue('https://cloud.ltd/nextcloud') | ||
getRootUrl.mockReturnValue('/nextcloud') | ||
const router = createRouter({ | ||
|
@@ -122,6 +122,47 @@ describe('autoLink', () => { | |
expect(getRoute(router, '/nextcloud/index.php/apps/test/foo')).toBe(null) | ||
}) | ||
|
||
it('should not get route from relative link without a leading slash', async () => { | ||
getBaseUrl.mockReturnValue('https://cloud.ltd/') | ||
getRootUrl.mockReturnValue('') | ||
const routerTalk = createRouter({ | ||
history: createMemoryHistory(''), | ||
routes: [ | ||
{ path: '/apps/spreed', name: 'root' }, | ||
{ path: '/call/:id', name: 'call' }, | ||
], | ||
}) | ||
routerTalk.push('/call/12345678') | ||
|
||
expect(getRoute(routerTalk, 'abcdefgh')).toBe(null) | ||
expect(getRoute(routerTalk, 'call/abcdefgh')).toBe(null) | ||
}) | ||
|
||
describe('Non-HTTP links', () => { | ||
const routerTalk = createRouter({ | ||
history: createMemoryHistory(''), | ||
routes: [ | ||
{ path: '/apps/spreed', name: 'root' }, | ||
{ path: '/call/:id', name: 'call' }, | ||
], | ||
}) | ||
getBaseUrl.mockReturnValue('https://cloud.ltd/') | ||
getRootUrl.mockReturnValue('') | ||
routerTalk.push('/call/12345678') | ||
|
||
it('should not handle mailto: link as a relative link', () => { | ||
expect(getRoute(routerTalk, 'mailto:[email protected]')).toBe(null) | ||
}) | ||
|
||
it('should not handle nc: link as a relative link', () => { | ||
expect(getRoute(routerTalk, 'nc://login')).toBe(null) | ||
}) | ||
|
||
it('should not handle a1.b-c+d: link as a relative link', () => { | ||
expect(getRoute(routerTalk, 'a1.b-c+d://action')).toBe(null) | ||
}) | ||
}) | ||
|
||
// getRoute doesn't have to guarantee Talk Desktop compatibility, but checking just in case | ||
describe('with Talk Desktop router - no router base and invalid getRootUrl', () => { | ||
it.each([ | ||
|