[Pharo-project] about relative URI
I decided to learn something new this evening so I started to read and write tests about URI Now I have a question testRelativeAuthority "self debug: #testRelativeAuthority" | uri relativeURIString | "A relative URI with authority. relative uri does not start with a scheme:." relativeURIString := '//www.pharo-project.org'. uri := URI fromString: relativeURIString.
self assert: (uri asString = relativeURIString). Is false because uri asString = 'www.pharo-project.org' and not '//www.pharo-project.org'
self deny: (uri isAbsolute). self assert: (uri isRelative). self assert: (uri authority asString = 'www.pharo-project.org'). self deny: (uri isOpaque). So does anybody know what is correct? Similarly testRelativeEmptyAuthority "self debug: #testRelativeEmptyAuthority" | uri uriString | uriString := '//'. "A relative URI with empty (but defined) authority." uri := URI fromString: uriString. self assert: (uri asString = uriString).
'' versus '//' self deny: (uri isAbsolute). self deny: (uri authority isNil). self deny: (uri isOpaque).
Thanks
Similarly printOn: of URIAuthority looks borken to me I should get userinfo@host and not @userinfohost So I fixed that... testUserInfo "self debug: #testUserInfo" | uri uriString | "[scheme:][//authority][path][?query][#fragment] where authority can be [user-info@]host[:port]" uriString := 'scheme://userinfo@host/'. uri := URI fromString: uriString. self assert: (uri asString = uriString). self assert: (uri authority userInfo = 'userinfo').
participants (1)
-
Stéphane Ducasse