mirror of
https://github.com/gnustep/libs-base.git
synced 2025-06-01 09:02:01 +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
7302652db0
commit
adc4c8d5e6
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>
|
2012-09-10 Richard Frith-Macdonald <rfm@gnu.org>
|
||||||
|
|
||||||
* Source/NSJSONSerialization.m:
|
* Source/NSJSONSerialization.m:
|
||||||
|
|
|
@ -1608,6 +1608,9 @@ static NSUInteger urlAlign;
|
||||||
- (NSString*) _pathWithEscapes: (BOOL)withEscapes
|
- (NSString*) _pathWithEscapes: (BOOL)withEscapes
|
||||||
{
|
{
|
||||||
NSString *path = nil;
|
NSString *path = nil;
|
||||||
|
|
||||||
|
if (YES == myData->isGeneric || 0 == myData->scheme)
|
||||||
|
{
|
||||||
unsigned int len = 3;
|
unsigned int len = 3;
|
||||||
|
|
||||||
if (_baseURL != nil)
|
if (_baseURL != nil)
|
||||||
|
@ -1647,6 +1650,7 @@ static NSUInteger urlAlign;
|
||||||
|
|
||||||
path = [NSString stringWithUTF8String: ptr];
|
path = [NSString stringWithUTF8String: ptr];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1750,6 +1754,8 @@ static NSUInteger urlAlign;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) resourceSpecifier
|
- (NSString*) resourceSpecifier
|
||||||
|
{
|
||||||
|
if (YES == myData->isGeneric)
|
||||||
{
|
{
|
||||||
NSRange range = [_urlString rangeOfString: @"://"];
|
NSRange range = [_urlString rangeOfString: @"://"];
|
||||||
|
|
||||||
|
@ -1787,6 +1793,11 @@ static NSUInteger urlAlign;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return [NSString stringWithUTF8String: myData->path];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString*) scheme
|
- (NSString*) scheme
|
||||||
{
|
{
|
||||||
|
@ -2025,6 +2036,9 @@ static NSUInteger urlAlign;
|
||||||
- (NSString*) fullPath
|
- (NSString*) fullPath
|
||||||
{
|
{
|
||||||
NSString *path = nil;
|
NSString *path = nil;
|
||||||
|
|
||||||
|
if (YES == myData->isGeneric || 0 == myData->scheme)
|
||||||
|
{
|
||||||
unsigned int len = 3;
|
unsigned int len = 3;
|
||||||
|
|
||||||
if (_baseURL != nil)
|
if (_baseURL != nil)
|
||||||
|
@ -2054,6 +2068,7 @@ static NSUInteger urlAlign;
|
||||||
ptr = [self _path: buf withEscapes: NO];
|
ptr = [self _path: buf withEscapes: NO];
|
||||||
path = [NSString stringWithUTF8String: ptr];
|
path = [NSString stringWithUTF8String: ptr];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -296,6 +296,12 @@ GSPathHandling("right");
|
||||||
PASS([url resourceDataUsingCache: NO] != nil,
|
PASS([url resourceDataUsingCache: NO] != nil,
|
||||||
"can load file URL with anchor");
|
"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;
|
[arp release]; arp = nil;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue