Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions SGDownload/Classes/SGDownloadTools.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ + (NSString *)replacehHomeDirectoryForFilePath:(NSString *)filePath
NSError * error;
NSRegularExpression * regex = [NSRegularExpression regularExpressionWithPattern:@"(\\w*-){4}(\\w*)" options:0 error:&error];
if (!error) {
#if !defined(TARGET_OS_SIMULATOR) || TARGET_OS_SIMULATOR
NSArray<NSTextCheckingResult *> *results =[regex matchesInString:filePath options:NSMatchingReportCompletion range:NSMakeRange(0, filePath.length)];
NSTextCheckingResult * match = results[1];
#else
NSTextCheckingResult * match = [regex firstMatchInString:filePath options:0 range:NSMakeRange(0, filePath.length)];
#endif
if (match) {
NSString * currentName = NSHomeDirectory().lastPathComponent;
filePath = [filePath stringByReplacingCharactersInRange:match.range withString:currentName];
Expand Down