2023-01-21 17:01:50 -09:00
|
|
|
import config from '../config'
|
|
|
|
|
|
|
|
|
|
export const baseUrl = (path) => {
|
|
|
|
|
const base = config.baseURL || ''
|
|
|
|
|
const parts = [base]
|
|
|
|
|
parts.push(path.replace(/^\//, ''))
|
|
|
|
|
return parts.join('/')
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-15 10:45:00 -08:00
|
|
|
export const shareUrl = (path) => {
|
|
|
|
|
if (config.shareURL !== '') {
|
|
|
|
|
const base = config.shareURL || ''
|
|
|
|
|
const parts = [base]
|
|
|
|
|
parts.push(path.replace(/^\//, ''))
|
|
|
|
|
return parts.join('/')
|
|
|
|
|
}
|
|
|
|
|
return baseUrl(path)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const sharePlayerUrl = (id) => {
|
2023-01-22 16:35:59 -09:00
|
|
|
const url = new URL(
|
2024-09-15 10:45:00 -08:00
|
|
|
shareUrl(config.publicBaseUrl + '/' + id),
|
2023-12-18 10:56:03 -09:00
|
|
|
window.location.href,
|
2023-01-22 16:35:59 -09:00
|
|
|
)
|
2023-01-21 17:01:50 -09:00
|
|
|
return url.href
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const shareStreamUrl = (id) => {
|
2024-09-15 10:45:00 -08:00
|
|
|
return shareUrl(config.publicBaseUrl + '/s/' + id)
|
2023-01-21 17:01:50 -09:00
|
|
|
}
|
|
|
|
|
|
2023-03-10 19:14:51 -09:00
|
|
|
export const shareDownloadUrl = (id) => {
|
2024-09-15 10:45:00 -08:00
|
|
|
return shareUrl(config.publicBaseUrl + '/d/' + id)
|
2023-03-10 19:14:51 -09:00
|
|
|
}
|
|
|
|
|
|
2025-05-26 13:39:05 -08:00
|
|
|
export const shareCoverUrl = (id, square) => {
|
|
|
|
|
return shareUrl(
|
|
|
|
|
config.publicBaseUrl +
|
|
|
|
|
'/img/' +
|
|
|
|
|
id +
|
|
|
|
|
'?size=300' +
|
|
|
|
|
(square ? '&square=true' : ''),
|
|
|
|
|
)
|
2023-01-21 17:01:50 -09:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const docsUrl = (path) => `https://www.navidrome.org${path}`
|