Refactor URL builders in UI

This commit is contained in:
Deluan
2023-01-21 21:01:50 -05:00
parent 84aa094e56
commit 357c0e1e19
6 changed files with 27 additions and 21 deletions
+23
View File
@@ -0,0 +1,23 @@
import config from '../config'
export const baseUrl = (path) => {
const base = config.baseURL || ''
const parts = [base]
parts.push(path.replace(/^\//, ''))
return parts.join('/')
}
export const shareUrl = (path) => {
const url = new URL(config.publicBaseUrl + '/' + path, window.location.href)
return url.href
}
export const shareStreamUrl = (id) => {
return baseUrl(config.publicBaseUrl + '/s/' + id)
}
export const shareCoverUrl = (id) => {
return baseUrl(config.publicBaseUrl + '/img/' + id + '?size=300')
}
export const docsUrl = (path) => `https://www.navidrome.org${path}`