Skip to content

Commit 3cdec42

Browse files
committed
对请求地址中的 ref、path 做一下特殊处理
1 parent daff636 commit 3cdec42

8 files changed

+14
-10
lines changed

Coding_iOS/Coding_iOS-Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</dict>
3333
</array>
3434
<key>CFBundleVersion</key>
35-
<string>3.2.201508271530</string>
35+
<string>3.2.201508282030</string>
3636
<key>LSRequiresIPhoneOS</key>
3737
<true/>
3838
<key>NSAppTransportSecurity</key>

Coding_iOS/Controllers/CodeViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ - (void)doSomethingWithResponse:(id)data andError:(NSError *)error{
100100

101101
- (void)refreshCodeViewData{
102102
if ([_myCodeFile.file.mode isEqualToString:@"image"]) {
103-
NSURL *imageUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@u/%@/p/%@/git/raw/%@/%@", [NSObject baseURLStr], _myProject.owner_user_name, _myProject.name, _myCodeFile.ref, _myCodeFile.file.path]];
103+
NSURL *imageUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@u/%@/p/%@/git/raw/%@/%@", [NSObject baseURLStr], _myProject.owner_user_name, _myProject.name, [_myCodeFile.ref URLEncoding_Coding], [_myCodeFile.file.path URLEncoding_Coding]]];
104104
DebugLog(@"imageUrl: %@", imageUrl);
105105
[self.webContentView loadRequest:[NSURLRequest requestWithURL:imageUrl]];
106106
}else if ([_myCodeFile.file.mode isEqualToString:@"file"]){

Coding_iOS/Controllers/CommitFilesViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
274274
FileChange *curFileChange = [curList objectAtIndex:indexPath.row];
275275

276276
FileChangeDetailViewController *vc = [FileChangeDetailViewController new];
277-
vc.linkUrlStr = [NSString stringWithFormat:@"api/user/%@/project/%@/git/commitDiffContent/%@/%@", _ownerGK, _projectName, _commitId, curFileChange.path];
277+
vc.linkUrlStr = [NSString stringWithFormat:@"api/user/%@/project/%@/git/commitDiffContent/%@/%@", _ownerGK, _projectName, _commitId, [curFileChange.path URLEncoding_Coding]];
278278

279279
vc.curProject = _curProject;
280280
vc.commitId = curFileChange.commitId;

Coding_iOS/Controllers/MRPRFilesViewController.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath
170170
FileChange *curFileChange = [curList objectAtIndex:indexPath.row];
171171

172172
FileChangeDetailViewController *vc = [FileChangeDetailViewController new];
173-
vc.linkUrlStr = [NSString stringWithFormat:@"%@?path=%@", [_curMRPR toFileLineChangesPath], curFileChange.path];
173+
vc.linkUrlStr = [NSString stringWithFormat:@"%@?path=%@", [_curMRPR toFileLineChangesPath], [curFileChange.path URLEncoding_Coding]];
174174
vc.curProject = _curProject;
175175
vc.commitId = curFileChange.commitId;
176176
vc.filePath = curFileChange.path;

Coding_iOS/Util/Manager/CodingNetAPIClient.m

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ - (void)requestJsonDataWithPath:(NSString *)aPath
6262
//log请求数据
6363
DebugLog(@"\n===========request===========:%@\n%@:\n%@", kNetworkMethodName[method], aPath, params);
6464
aPath = [aPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
65-
aPath = [aPath stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
6665
// 发起请求
6766
switch (method) {
6867
case Get:{

Coding_iOS/Util/Manager/Coding_NetAPIManager.m

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -908,8 +908,8 @@ - (void)request_CloseShareHash:(NSString *)hashStr andBlock:(void (^)(id data, N
908908

909909
#pragma mark Code
910910
- (void)request_CodeTree:(CodeTree *)codeTree withPro:(Project *)project codeTreeBlock:(void (^)(id codeTreeData, NSError *codeTreeError))block{
911-
NSString *treePath = [NSString stringWithFormat:@"api/user/%@/project/%@/git/tree/%@/%@", project.owner_user_name, project.name, codeTree.ref, codeTree.path];
912-
NSString *treeinfoPath = [NSString stringWithFormat:@"api/user/%@/project/%@/git/treeinfo/%@/%@", project.owner_user_name, project.name, codeTree.ref, codeTree.path];
911+
NSString *treePath = [NSString stringWithFormat:@"api/user/%@/project/%@/git/tree/%@/%@", project.owner_user_name, project.name, [codeTree.ref URLEncoding_Coding], [codeTree.path URLEncoding_Coding]];
912+
NSString *treeinfoPath = [NSString stringWithFormat:@"api/user/%@/project/%@/git/treeinfo/%@/%@", project.owner_user_name, project.name, [codeTree.ref URLEncoding_Coding], [codeTree.path URLEncoding_Coding]];
913913
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:treePath withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
914914
if (data) {
915915
id resultData = [data valueForKeyPath:@"data"];
@@ -936,7 +936,7 @@ - (void)request_CodeTree:(CodeTree *)codeTree withPro:(Project *)project codeTre
936936
}
937937

938938
- (void)request_CodeFile:(CodeFile *)codeFile withPro:(Project *)project andBlock:(void (^)(id data, NSError *error))block{
939-
NSString *filePath = [NSString stringWithFormat:@"api/user/%@/project/%@/git/blob/%@/%@", project.owner_user_name, project.name, codeFile.ref, codeFile.path];
939+
NSString *filePath = [NSString stringWithFormat:@"api/user/%@/project/%@/git/blob/%@/%@", project.owner_user_name, project.name, [codeFile.ref URLEncoding_Coding], [codeFile.path URLEncoding_Coding]];
940940
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:filePath withParams:nil withMethodType:Get andBlock:^(id data, NSError *error) {
941941
if (data) {
942942
[MobClick event:kUmeng_Event_Request_Get label:@"代码文件内容"];
@@ -966,7 +966,7 @@ - (void)request_CodeBranchOrTagWithPath:(NSString *)path withPro:(Project *)proj
966966
}
967967

968968
- (void)request_Commits:(Commits *)curCommits withPro:(Project *)project andBlock:(void (^)(id data, NSError *error))block{
969-
NSString *path = [NSString stringWithFormat:@"api/user/%@/project/%@/git/commits/%@/%@", project.owner_user_name, project.name, curCommits.ref, curCommits.path];
969+
NSString *path = [NSString stringWithFormat:@"api/user/%@/project/%@/git/commits/%@/%@", project.owner_user_name, project.name, [curCommits.ref URLEncoding_Coding], [curCommits.path URLEncoding_Coding]];
970970
[[CodingNetAPIClient sharedJsonClient] requestJsonDataWithPath:path withParams:[curCommits toParams] withMethodType:Get andBlock:^(id data, NSError *error) {
971971
if (data) {
972972
[MobClick event:kUmeng_Event_Request_Get label:@"提交记录_列表"];

Coding_iOS/Util/OC_Category/NSString+Common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
+ (NSString *)userAgentStr;
1515

1616
- (NSString *)URLEncoding;
17+
- (NSString *)URLEncoding_Coding;
1718
- (NSString *)URLDecoding;
1819
- (NSString *)md5Str;
1920
- (NSString*) sha1Str;

Coding_iOS/Util/OC_Category/NSString+Common.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ - (NSString *)URLEncoding
3030
kCFStringEncodingUTF8 ));
3131
return result;
3232
}
33-
33+
- (NSString *)URLEncoding_Coding{
34+
NSString *result = [self stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
35+
result = [result stringByReplacingOccurrencesOfString: @"%2F" withString: @"/"];
36+
return result;
37+
}
3438
- (NSString *)URLDecoding
3539
{
3640
NSMutableString * string = [NSMutableString stringWithString:self];

0 commit comments

Comments
 (0)