leanote 图片下载不全, https的图片 #25

This commit is contained in:
life
2015-11-08 15:50:12 +08:00
parent fee6ac7b30
commit 22b6bcebbd

View File

@@ -637,16 +637,26 @@
if([Common isBlankString:content]) {
return content;
}
// https
NSString *host = [[UserService getHost] lowercaseString];
if ([host rangeOfString:@"https"].location == NSNotFound) {
host = [host stringByReplacingOccurrencesOfString:@"http" withString:@"https*"];
}
else {
host = [host stringByReplacingOccurrencesOfString:@"https" withString:@"https*"];
}
// markdown
if(!isMarkdown) {
NSString *pattern = [NSString stringWithFormat:@"src=('|\")%@/(api/)*file/(outputImage|getImage)\\?fileId=([a-z0-9A-Z]{24})('|\")", [UserService getHost]];
NSString *pattern = [NSString stringWithFormat:@"src=('|\")%@/(api/)*file/(outputImage|getImage)\\?fileId=([a-z0-9A-Z]{24})('|\")", host];
NSRegularExpression *regularExpression = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:nil];
content = [regularExpression stringByReplacingMatchesInString:content options:0 range:NSMakeRange(0, content.length) withTemplate:@"src=\"leanote://getImage?fileId=$4\""];
}
// markdown
else {
NSString *pattern = [NSString stringWithFormat: @"!\\[(.*?)\\]\\(%@/(api/)*file/(outputImage|getImage)\\?fileId=([a-z0-9A-Z]{24})\\)", [UserService getHost]];
NSString *pattern = [NSString stringWithFormat: @"!\\[(.*?)\\]\\(%@/(api/)*file/(outputImage|getImage)\\?fileId=([a-z0-9A-Z]{24})\\)", host];
NSRegularExpression *regularExpression = [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:nil];
content = [regularExpression stringByReplacingMatchesInString:content options:0 range:NSMakeRange(0, content.length) withTemplate:@"![$1](leanote://getImage?fileId=$4)"];
}