Fix channels URL parsing

This commit is contained in:
Arkadiusz Fal
2022-06-26 14:32:15 +02:00
parent ed303a2368
commit d0ef3631b6
2 changed files with 5 additions and 4 deletions

View File

@@ -75,13 +75,12 @@ struct URLParser {
}
var channelName: String? {
guard destination == .channel else { return nil }
guard hasAnyOfPrefixes(path, ["c/", "/c/"]) else { return nil }
return removePrefixes(path, Self.prefixes[.channel]!.map { [$0, "/"].joined() })
}
var channelID: String? {
guard destination == .channel else { return nil }
guard hasAnyOfPrefixes(path, ["channel/", "/channel/"]) else { return nil }
return removePrefixes(path, Self.prefixes[.channel]!.map { [$0, "/"].joined() })
}
@@ -95,7 +94,7 @@ struct URLParser {
}
private func hasAnyOfPrefixes(_ value: String, _ prefixes: [String]) -> Bool {
return prefixes.contains { value.hasPrefix($0) }
prefixes.contains { value.hasPrefix($0) }
}
private func removePrefixes(_ value: String, _ prefixes: [String]) -> String {