mirror of
https://github.com/austinried/subtracks.git
synced 2025-12-29 17:39:27 +01:00
encode values before using in url (#81)
This commit is contained in:
parent
41f00ef3f1
commit
5169b726ce
@ -65,13 +65,13 @@ export class SubsonicApiClient {
|
|||||||
this.username = server.username
|
this.username = server.username
|
||||||
|
|
||||||
this.params = new URLSearchParams()
|
this.params = new URLSearchParams()
|
||||||
this.params.append('u', server.username)
|
this.params.append('u', encodeURIComponent(server.username))
|
||||||
|
|
||||||
if (server.usePlainPassword) {
|
if (server.usePlainPassword) {
|
||||||
this.params.append('p', server.plainPassword)
|
this.params.append('p', encodeURIComponent(server.plainPassword))
|
||||||
} else {
|
} else {
|
||||||
this.params.append('t', server.token)
|
this.params.append('t', encodeURIComponent(server.token))
|
||||||
this.params.append('s', server.salt)
|
this.params.append('s', encodeURIComponent(server.salt))
|
||||||
}
|
}
|
||||||
|
|
||||||
this.params.append('v', '1.13.0')
|
this.params.append('v', '1.13.0')
|
||||||
@ -79,16 +79,16 @@ export class SubsonicApiClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private buildUrl(method: string, params?: { [key: string]: any }): string {
|
private buildUrl(method: string, params?: { [key: string]: any }): string {
|
||||||
let query = this.params.toString()
|
let urlParams = this.params.toString()
|
||||||
if (params) {
|
if (params) {
|
||||||
const urlParams = this.obj2Params(params)
|
const methodParams = this.obj2Params(params)
|
||||||
if (urlParams) {
|
if (methodParams) {
|
||||||
query += '&' + urlParams.toString()
|
urlParams += '&' + methodParams.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// *.view was present on all method names in API 1.14.0 and earlier
|
// *.view was present on all method names in API 1.14.0 and earlier
|
||||||
return `${this.address}/rest/${method}.view?${query}`
|
return `${this.address}/rest/${method}.view?${urlParams}`
|
||||||
}
|
}
|
||||||
|
|
||||||
private async apiGetXml(method: string, params?: { [key: string]: any }): Promise<Document> {
|
private async apiGetXml(method: string, params?: { [key: string]: any }): Promise<Document> {
|
||||||
@ -123,7 +123,7 @@ export class SubsonicApiClient {
|
|||||||
if (obj[key] === undefined || obj[key] === null) {
|
if (obj[key] === undefined || obj[key] === null) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
params.append(key, String(obj[key]))
|
params.append(key, encodeURIComponent(String(obj[key])))
|
||||||
}
|
}
|
||||||
|
|
||||||
return params
|
return params
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user