Skip to content

Commit 683ad26

Browse files
committed
chore: tighten up scheme support
1 parent ff8fd1b commit 683ad26

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

package/shared-native/android/StreamVideoThumbnailGenerator.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ object StreamVideoThumbnailGenerator {
112112

113113
when {
114114
scheme.isNullOrEmpty() -> retriever.setDataSource(url)
115-
scheme == "http" || scheme == "https" -> retriever.setDataSource(url, emptyMap())
116-
else -> retriever.setDataSource(context, uri)
115+
scheme == "content" || scheme == "file" -> retriever.setDataSource(context, uri)
116+
else ->
117+
throw IllegalArgumentException(
118+
"Unsupported video URI scheme for thumbnail generation: $scheme. Local assets only.",
119+
)
117120
}
118121
}
119122

package/shared-native/ios/StreamVideoThumbnailGenerator.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public final class StreamVideoThumbnailGenerator: NSObject {
165165
return resolvePhotoLibraryAsset(url: url)
166166
}
167167

168-
if let normalizedURL = normalizeURL(url) {
168+
if let normalizedURL = normalizeLocalURL(url) {
169169
return AVURLAsset(url: normalizedURL)
170170
}
171171

@@ -220,9 +220,13 @@ public final class StreamVideoThumbnailGenerator: NSObject {
220220
.trimmingCharacters(in: CharacterSet(charactersIn: "/")) ?? ""
221221
}
222222

223-
private static func normalizeURL(_ url: String) -> URL? {
224-
if let parsedURL = URL(string: url), parsedURL.scheme != nil {
225-
return parsedURL
223+
private static func normalizeLocalURL(_ url: String) -> URL? {
224+
if let parsedURL = URL(string: url), let scheme = parsedURL.scheme?.lowercased() {
225+
if scheme == "file" {
226+
return parsedURL
227+
}
228+
229+
return nil
226230
}
227231

228232
return URL(fileURLWithPath: url)

0 commit comments

Comments
 (0)