mirror of
https://github.com/mattermost/focalboard.git
synced 2024-12-03 08:45:40 +02:00
fix double slash on buildURL (#615)
This commit is contained in:
parent
1f7470aca7
commit
c86d9b9ff5
@ -34,4 +34,36 @@ describe('utils', () => {
|
||||
windowAsAny.openInNewBrowser = null
|
||||
})
|
||||
})
|
||||
|
||||
describe('test - buildURL', () => {
|
||||
test('buildURL, no base', () => {
|
||||
expect(Utils.buildURL('test', true)).toBe('http://localhost/test')
|
||||
expect(Utils.buildURL('/test', true)).toBe('http://localhost/test')
|
||||
|
||||
expect(Utils.buildURL('test')).toBe('/test')
|
||||
expect(Utils.buildURL('/test')).toBe('/test')
|
||||
})
|
||||
|
||||
test('buildURL, base no slash', () => {
|
||||
const windowAsAny = window as any
|
||||
windowAsAny.baseURL = 'base'
|
||||
|
||||
expect(Utils.buildURL('test', true)).toBe('http://localhost/base/test')
|
||||
expect(Utils.buildURL('/test', true)).toBe('http://localhost/base/test')
|
||||
|
||||
expect(Utils.buildURL('test')).toBe('base/test')
|
||||
expect(Utils.buildURL('/test')).toBe('base/test')
|
||||
})
|
||||
|
||||
test('buildUrl, base with slash', () => {
|
||||
const windowAsAny = window as any
|
||||
windowAsAny.baseURL = '/base/'
|
||||
|
||||
expect(Utils.buildURL('test', true)).toBe('http://localhost/base/test')
|
||||
expect(Utils.buildURL('/test', true)).toBe('http://localhost/base/test')
|
||||
|
||||
expect(Utils.buildURL('test')).toBe('base/test')
|
||||
expect(Utils.buildURL('/test')).toBe('base/test')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
@ -333,6 +333,9 @@ class Utils {
|
||||
finalPath = baseURL + '/' + path
|
||||
}
|
||||
if (absolute) {
|
||||
if (finalPath.indexOf('/') === 0) {
|
||||
finalPath = finalPath.slice(1)
|
||||
}
|
||||
return window.location.origin + '/' + finalPath
|
||||
}
|
||||
return finalPath
|
||||
|
Loading…
Reference in New Issue
Block a user