mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-31 16:50:58 +00:00
add support for data:,xxx style URL
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@35568 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
30934c87eb
commit
ae328505c2
3 changed files with 111 additions and 84 deletions
|
@ -1,3 +1,9 @@
|
|||
2012-09-16 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSURL.m:
|
||||
* Tests/base/NSURL/basic.m:
|
||||
Add support for data: URL
|
||||
|
||||
2012-09-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSJSONSerialization.m:
|
||||
|
|
|
@ -1608,6 +1608,9 @@ static NSUInteger urlAlign;
|
|||
- (NSString*) _pathWithEscapes: (BOOL)withEscapes
|
||||
{
|
||||
NSString *path = nil;
|
||||
|
||||
if (YES == myData->isGeneric || 0 == myData->scheme)
|
||||
{
|
||||
unsigned int len = 3;
|
||||
|
||||
if (_baseURL != nil)
|
||||
|
@ -1647,6 +1650,7 @@ static NSUInteger urlAlign;
|
|||
|
||||
path = [NSString stringWithUTF8String: ptr];
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
|
@ -1751,6 +1755,8 @@ static NSUInteger urlAlign;
|
|||
|
||||
- (NSString*) resourceSpecifier
|
||||
{
|
||||
if (YES == myData->isGeneric)
|
||||
{
|
||||
NSRange range = [_urlString rangeOfString: @"://"];
|
||||
|
||||
if (range.length > 0)
|
||||
|
@ -1786,6 +1792,11 @@ static NSUInteger urlAlign;
|
|||
return _urlString;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return [NSString stringWithUTF8String: myData->path];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString*) scheme
|
||||
|
@ -2025,6 +2036,9 @@ static NSUInteger urlAlign;
|
|||
- (NSString*) fullPath
|
||||
{
|
||||
NSString *path = nil;
|
||||
|
||||
if (YES == myData->isGeneric || 0 == myData->scheme)
|
||||
{
|
||||
unsigned int len = 3;
|
||||
|
||||
if (_baseURL != nil)
|
||||
|
@ -2054,6 +2068,7 @@ static NSUInteger urlAlign;
|
|||
ptr = [self _path: buf withEscapes: NO];
|
||||
path = [NSString stringWithUTF8String: ptr];
|
||||
}
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
|
|
|
@ -296,6 +296,12 @@ GSPathHandling("right");
|
|||
PASS([url resourceDataUsingCache: NO] != nil,
|
||||
"can load file URL with anchor");
|
||||
|
||||
url = [NSURL URLWithString: @"data:,a23"];
|
||||
PASS_EQUAL([url scheme], @"data", "can get scheme of data URL");
|
||||
PASS_EQUAL([url path], nil, "path of data URL is nil");
|
||||
PASS_EQUAL([url host], nil, "host of data URL is nil");
|
||||
PASS_EQUAL([url resourceSpecifier], @",a23", "resourceSpecifier of data URL");
|
||||
PASS_EQUAL([url absoluteString], @"data:,a23", "can get string of data URL");
|
||||
|
||||
[arp release]; arp = nil;
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue