forked from qiniu/objc-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change http scheme logic: prefer using url self scheme
- Loading branch information
YangSen-qn
committed
Nov 16, 2023
1 parent
e7dcaed
commit 9c54854
Showing
4 changed files
with
58 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// QNUrlUtils.h | ||
// QiniuSDK | ||
// | ||
// Created by yangsen on 2023/11/16. | ||
// Copyright © 2023 Qiniu. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface QNUrlUtils : NSObject | ||
|
||
+ (NSString *)setHostScheme:(NSString *)host useHttps:(BOOL)useHttps; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// | ||
// QNUrlUtils.m | ||
// QiniuSDK | ||
// | ||
// Created by yangsen on 2023/11/16. | ||
// Copyright © 2023 Qiniu. All rights reserved. | ||
// | ||
|
||
#import "QNUrlUtils.h" | ||
|
||
@implementation QNUrlUtils | ||
|
||
+ (NSString *)setHostScheme:(NSString *)host useHttps:(BOOL)useHttps { | ||
if (host == nil || host.length == 0) { | ||
return nil; | ||
} | ||
|
||
if ([host hasPrefix:@"http://"] || [host hasPrefix:@"https://"]) { | ||
return host; | ||
} | ||
|
||
return [NSString stringWithFormat:@"%@%@", (useHttps ? @"https://" : @"http://"), host]; | ||
} | ||
|
||
@end |