fix url redaction crash

This commit is contained in:
dirtydishes 2026-05-24 23:51:47 -04:00
parent d46004a98e
commit 6e220e6df9
4 changed files with 12 additions and 2 deletions

View file

@ -6,6 +6,7 @@ struct StreamResolverTests {
testClassifierPrefersObservedDirectFile()
testResolverSelectsUnsupportedDirectURLAndHeaders()
testResolverRejectsHLSOnlyResponse()
testRedactorHandlesPercentEncodedPath()
print("StreamResolverTests passed")
}
@ -67,6 +68,13 @@ struct StreamResolverTests {
assert(stream == nil, "Expected HLS-only resolver response to stay out of native playback")
}
private static func testRedactorHandlesPercentEncodedPath() {
let original = "https://cdn.example.test/video/abcdefghijklmnopqrstuvwxyz012345/%E2%9C%93.mp4?token=secret#fragment"
let redacted = URLRedactor.redactedURLString(original)
assertEqual(redacted, "https://cdn.example.test/video/%5Bredacted%5D/%E2%9C%93.mp4")
}
private static func assertEqual<T: Equatable>(_ actual: T?, _ expected: T, file: StaticString = #file, line: UInt = #line) {
assert(actual == expected, "Expected \(String(describing: expected)), got \(String(describing: actual))", file: file, line: line)
}