Various fixes

This commit is contained in:
Ilya Laktyushin
2024-04-30 12:58:20 +04:00
parent 9723a875b2
commit 2b6a8e202e
33 changed files with 263 additions and 65 deletions

View File

@@ -1204,7 +1204,11 @@ public func resolveUrlImpl(context: AccountContext, peerId: PeerId?, url: String
var url = url
let lowercasedUrl = url.lowercased()
if (lowercasedUrl.hasPrefix(scheme) && (lowercasedUrl.hasSuffix(".\(basePath)") || lowercasedUrl.contains(".\(basePath)/") || lowercasedUrl.contains(".\(basePath)?"))) {
url = basePrefix + String(url[scheme.endIndex...]).replacingOccurrences(of: ".\(basePath)/", with: "").replacingOccurrences(of: ".\(basePath)", with: "")
let restUrl = String(url[scheme.endIndex...])
if let slashRange = restUrl.range(of: "/"), let baseRange = restUrl.range(of: basePath), slashRange.lowerBound < baseRange.lowerBound {
} else {
url = basePrefix + restUrl.replacingOccurrences(of: ".\(basePath)/", with: "/").replacingOccurrences(of: ".\(basePath)", with: "")
}
}
if url.lowercased().hasPrefix(basePrefix) {
if let internalUrl = parseInternalUrl(sharedContext: context.sharedContext, query: String(url[basePrefix.endIndex...])) {