ADURL 0.1.0

ADURL 0.1.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新版本2015年3月

未知 维护。



ADURL 0.1.0

  • 作者
  • jden

基于 node 的 url 模块的 URL 构建类

用法

#import "ADURL.h"

ADURL *url = [ADURL new];
url.protocol = @"http";
url.hostname = @"agilemd.com";
url.path = @"/foo";
url.query[@"bar"] = @"baz";

url.href;
// => @"http://agilemd.com/foo?bar=baz"

额外:JavaScript 样式的 encodeURIcomponent 和 decodeURIcomponent 类方法

[ADURL encodeURIcomponent:@"anyone home?"];
// => @"anyone%20home%3F"
[ADURL decodeURIcomponent:@"anyone%20home%3F"];
// => @"anyone home?"

安装

使用 Cocoapods,将其添加到您的 podfile

pod 'ADURL'

API

@interface ADURL : NSObject
/**
 * The full URL that was originally parsed. Both the protocol and host are
 * lowercased.
 * Example: 'http://user:[email protected]:8080/p/a/t/h?query=string#hash'
 */
@property (nonatomic, strong) NSString * href;

/**
 * The request protocol, lowercased.
 * Example: 'http:'
 */
@property (nonatomic, strong) NSString * protocol;

/**
 * The authentication information portion of a URL.
 * Example: 'user:pass'
 */
@property (nonatomic, strong) NSString * auth;

/**
 * The full lowercased host portion of the URL, including port information.
 * Example: 'host.com:8080'
 */
@property (nonatomic, strong) NSString * host;

/**
 * Just the lowercased hostname portion of the host.
 * Example: 'host.com'
 */
@property (nonatomic, strong) NSString * hostname;

/**
 * The port number portion of the host.
 * Example: '8080'
 */
@property (nonatomic) NSInteger port;

/**
 * Concatenation of pathname and search.
 * Example: '/p/a/t/h?query=string'
 */
@property (nonatomic, strong) NSString * path;

/**
 * The path section of the URL, that comes after the host and before the query,
 * including the initial slash if present.
 * Example: '/p/a/t/h'
 */
@property (nonatomic, strong) NSString * pathname;

/**
 * The 'query string' portion of the URL, including the leading question mark.
 * Example: '?query=string'
 */
@property (nonatomic, strong) NSString * search;


/**
 * The querystring as a dictionary
 * Example: @{@"query": @"string"}
 */
@property (nonatomic, readonly, strong) NSMutableDictionary * query;

/**
 * The 'fragment' portion of the URL including the pound-sign.
 * Example: '#hash'
 */
@property (nonatomic, strong) NSString * hash;

+ (ADURL *) parse: (NSString *) urlStr;
+ (NSString *) encodeURIcomponent: (NSString *) str;
+ (NSString *) decodeURIcomponent: (NSString *) str;
@end

尚未实现

  • ADURL.href 的解析器/设置器,[ADURL parse:]

运行测试

在 Xcode 中运行或在项目目录中运行 $ make test

贡献者

许可证

MIT. (c) MMXIII AgileMD. 查看 LICENSE.md