Fix: share links for URLs containing 'api' incorrect in dropdown (#4701)

This commit is contained in:
shamoon
2023-11-29 11:10:55 -08:00
committed by GitHub
parent 0e0f65c69a
commit e5f5579639
2 changed files with 24 additions and 1 deletions

View File

@@ -192,4 +192,24 @@ describe('ShareLinksDropdownComponent', () => {
component.share(link)
// expect(navigatorSpy).toHaveBeenCalledWith({ url: component.getShareUrl(link) })
})
it('should correctly generate share URLs', () => {
environment.apiBaseUrl = 'http://example.com/api/'
expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual(
'http://example.com/share/123abc123'
)
environment.apiBaseUrl = 'http://example.domainwithapiinit.com/api/'
expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual(
'http://example.domainwithapiinit.com/share/123abc123'
)
environment.apiBaseUrl = 'http://example.domainwithapiinit.com:1234/api/'
expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual(
'http://example.domainwithapiinit.com:1234/share/123abc123'
)
environment.apiBaseUrl =
'http://example.domainwithapiinit.com:1234/subpath/api/'
expect(component.getShareUrl({ slug: '123abc123' } as any)).toEqual(
'http://example.domainwithapiinit.com:1234/subpath/share/123abc123'
)
})
})