mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-02-07 10:49:39 +00:00
Fix API including basepath in tracks contentUrl
This commit is contained in:
parent
a58d486c44
commit
aebb3ff413
6 changed files with 16 additions and 12 deletions
|
|
@ -1,5 +1,5 @@
|
|||
export default class AudioTrack {
|
||||
constructor(track, userToken) {
|
||||
constructor(track, userToken, routerBasePath) {
|
||||
this.index = track.index || 0
|
||||
this.startOffset = track.startOffset || 0 // Total time of all previous tracks
|
||||
this.duration = track.duration || 0
|
||||
|
|
@ -9,20 +9,27 @@ export default class AudioTrack {
|
|||
this.metadata = track.metadata || {}
|
||||
|
||||
this.userToken = userToken
|
||||
this.routerBasePath = routerBasePath || ''
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for CastPlayer
|
||||
*/
|
||||
get fullContentUrl() {
|
||||
if (!this.contentUrl || this.contentUrl.startsWith('http')) return this.contentUrl
|
||||
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
return `${process.env.serverUrl}${this.contentUrl}?token=${this.userToken}`
|
||||
}
|
||||
return `${window.location.origin}${this.contentUrl}?token=${this.userToken}`
|
||||
return `${window.location.origin}${this.routerBasePath}${this.contentUrl}?token=${this.userToken}`
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for LocalPlayer
|
||||
*/
|
||||
get relativeContentUrl() {
|
||||
if (!this.contentUrl || this.contentUrl.startsWith('http')) return this.contentUrl
|
||||
|
||||
return this.contentUrl + `?token=${this.userToken}`
|
||||
return `${this.routerBasePath}${this.contentUrl}?token=${this.userToken}`
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue