mirror of
https://github.com/whoeevee/EeveeSpotifyReborn.git
synced 2026-01-09 00:23:20 +01:00
fix: improve lyrics fetching and query encoding for special characters (#594)
* chore: gitignore .vscode * fix(lrclib): use 'get' API, return empty lines when instrumental * build: add workflow_dispatch trigger * fix: encode query strings with stricter character set
This commit is contained in:
1 parent
ba407d7ed7
commit
85a002b9b3
7 files changed
+48
-27
No files matched your search
@@ -0,0 +1,9 @@
|
||||
import Foundation
|
||||
|
||||
extension CharacterSet {
|
||||
static var urlQueryAllowedStrict: CharacterSet {
|
||||
var allowed = CharacterSet.urlQueryAllowed
|
||||
allowed.remove(charactersIn: "/?@&=+$")
|
||||
return allowed
|
||||
}
|
||||
}
|
||||
@@ -3,9 +3,13 @@ import Foundation
|
||||
extension Dictionary {
|
||||
var queryString: String {
|
||||
return self
|
||||
.compactMap({ (key, value) -> String in
|
||||
return "\(key)=\(value)"
|
||||
.compactMap({ (key, value) -> String? in
|
||||
guard let keyString = "\(key)".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowedStrict),
|
||||
let valueString = "\(value)".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowedStrict) else {
|
||||
return nil
|
||||
}
|
||||
return "\(keyString)=\(valueString)"
|
||||
})
|
||||
.joined(separator: "&")
|
||||
.joined(separator: "&")
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user