45 lines
2.6 KiB
Plaintext
45 lines
2.6 KiB
Plaintext
local fn ParseURL( urlStr as CFStringRef ) as CFStringRef
|
|
CFMutableStringRef mutStr = fn MutableStringNew
|
|
URLQueryItemRef queryItem
|
|
|
|
URLComponentsRef components = fn URLComponentsWithString( urlStr )
|
|
CFStringRef scheme = fn URLComponentsScheme( components )
|
|
CFStringRef domain = fn URLComponentsHost( components )
|
|
CFNumberRef port = fn URLPort( fn URLWithString( urlStr ) )
|
|
CFStringRef path = fn URLComponentsPath( components )
|
|
CFStringRef user = fn URLComponentsUser( components )
|
|
CFStringRef query = fn URLComponentsQuery( components )
|
|
CFStringRef fragment = fn URLComponentsFragment( components )
|
|
CFStringRef password = fn URLComponentsPassword( components )
|
|
CFArrayRef queryItems = fn URLComponentsQueryItems( components )
|
|
|
|
if urlStr then MutableStringAppendString( mutStr, fn StringWithFormat( @"url: %@\n", urlStr ) )
|
|
if scheme then MutableStringAppendString( mutStr, fn StringWithFormat( @"scheme: %@\n", scheme ) )
|
|
if domain then MutableStringAppendString( mutStr, fn StringWithFormat( @"domain: %@\n", domain ) )
|
|
if port then MutableStringAppendString( mutStr, fn StringWithFormat( @"port: :%@\n", port ) )
|
|
if path then MutableStringAppendString( mutStr, fn StringWithFormat( @"path: %@\n", path ) )
|
|
if user then MutableStringAppendString( mutStr, fn StringWithFormat( @"user: %@\n", user ) )
|
|
if password then MutableStringAppendString( mutStr, fn StringWithFormat( @"password: %@\n", password ) )
|
|
if query then MutableStringAppendString( mutStr, fn StringWithFormat( @"query: %@\n", query ) )
|
|
if fragment then MutableStringAppendString( mutStr, fn StringWithFormat( @"fragment: %@\n", fragment ) )
|
|
|
|
for queryItem in queryItems
|
|
CFStringRef name = fn URLQueryItemName( queryItem )
|
|
CFStringRef value = fn URLQueryItemValue( queryItem )
|
|
MutableStringAppendFormat( mutStr, @"%@: %@\n", name, value )
|
|
next
|
|
end fn = fn StringWithString( mutStr )
|
|
|
|
print fn ParseURL( @"foo://example.com:8042/over/there?name=ferret#nose" )
|
|
print fn ParseURL( @"urn:example:animal:ferret:nose" )
|
|
print fn ParseURL( @"ftp://ftp.is.co.za/rfc/rfc1808.txt" )
|
|
print fn ParseURL( @"http://www.ietf.org/rfc/rfc2396.txt#header1" )
|
|
print fn ParseURL( @"ldap://[2001:db8::7]/c=GB?objectClass=one&objectClass=two" )
|
|
print fn ParseURL( @"mailto:John.Doe@example.com" )
|
|
print fn ParseURL( @"news:comp.infosystems.www.servers.unix" )
|
|
print fn ParseURL( @"tel:+1-816-555-1212" )
|
|
print fn ParseURL( @"telnet://192.0.2.16:80/" )
|
|
print fn ParseURL( @"urn:oasis:names:specification:docbook:dtd:xml:4.1.2" )
|
|
|
|
HandleEvents
|