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:
rfm 2012-09-16 07:39:18 +00:00
parent 7302652db0
commit adc4c8d5e6
3 changed files with 111 additions and 84 deletions

View file

@ -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:

View file

@ -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;
}
@ -1750,6 +1754,8 @@ static NSUInteger urlAlign;
}
- (NSString*) resourceSpecifier
{
if (YES == myData->isGeneric)
{
NSRange range = [_urlString rangeOfString: @"://"];
@ -1787,6 +1793,11 @@ static NSUInteger urlAlign;
}
}
}
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;
}

View file

@ -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;