react-native-compressor 1.8.13 → 1.8.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ios/Utils/Utils.swift
CHANGED
|
@@ -127,4 +127,20 @@ class Utils {
|
|
|
127
127
|
return fileSize
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
+
static func slashifyFilePath(path: String?) -> String? {
|
|
131
|
+
if let path = path {
|
|
132
|
+
if path.hasPrefix("file:///") {
|
|
133
|
+
return path
|
|
134
|
+
} else if path.hasPrefix("/") {
|
|
135
|
+
return path.replacingOccurrences(of: "^/+", with: "file:///", options: .regularExpression, range: nil)
|
|
136
|
+
} else {
|
|
137
|
+
// Ensure leading schema with a triple slash
|
|
138
|
+
let regex = try! NSRegularExpression(pattern: "^file:/*")
|
|
139
|
+
let modifiedPath = regex.stringByReplacingMatches(in: path, options: [], range: NSRange(location: 0, length: path.utf16.count), withTemplate: "file:///")
|
|
140
|
+
return modifiedPath.hasPrefix("file:///") ? modifiedPath : "file:///" + modifiedPath
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return path
|
|
144
|
+
}
|
|
145
|
+
|
|
130
146
|
}
|
|
@@ -371,7 +371,7 @@ class VideoCompressor {
|
|
|
371
371
|
}
|
|
372
372
|
return
|
|
373
373
|
} else if !videoPath.contains("ph://") {
|
|
374
|
-
completionHandler(videoPath)
|
|
374
|
+
completionHandler(Utils.slashifyFilePath(path: videoPath)!)
|
|
375
375
|
return
|
|
376
376
|
}
|
|
377
377
|
let assetId = videoPath.replacingOccurrences(of: "ph://", with: "")
|