[Q] Isn't 'file://foo/bar' asUrl supposed to give a relative
FileUrl?
Michael Rueger
michael at squeakland.org
Sun Aug 17 23:55:01 UTC 2003
Lex Spoon wrote:
> Bert Freudenberg <bert at isg.cs.uni-magdeburg.de> wrote:
>
>
>>>It's a useful extension. Such a URL is not covered in the RFC's, but it
>>>is useful and people do it.
>>
>>I don't think it's useful. I'd consider it even bad and confusing (like
>>this discussion clearly shows) because the power of URLs stems from the
>>simple fact that it is *only* a well-defined string. Also, the code
>>becomes rather ugly, with "isAbsolute ifTrue: [...]" scattered around
>>the place.
A few things from the RFC are below.
The problem that I have with the current implementation is not that it
is incomplete, but it does too many things. URIs are basically strings
without any semantic meaning in respect to the scheme. The scheme only
becomes "meaningful" through its interpretation as a protocol. So the
right thing to do IM(H)O is to have "pure" URIs like in my package and
dispatch any operations to the protocol counter part, be it the file
system or an ftp or http client.
The problems that are evident in all these hacks throughout the URL
classes stem from trying to interpret non-conforming URI constructs in a
"smart" way. If you actually stick to the spec, especially the part
Indeed, the
base URI is necessary to define the semantics of any relative URI
reference; without it, a relative reference is meaningless.
none of the discussed problems are an issue.
E.g., 'g' asUrl -> http://g/ is one of these smart things that are just
plain incorrect.
Michael
-------------
URI-reference = [ absoluteURI | relativeURI ] [ "#" fragment ]
The syntax for relative URI is a shortened form of that for absolute
URI, where some prefix of the URI is missing and certain path
components ("." and "..") have a special meaning when, and only when,
interpreting a relative path. The relative URI syntax is defined in
Section 5.
A relative reference that does not begin with a scheme name or a
slash character is termed a relative-path reference.
5.1. Establishing a Base URI
The term "relative URI" implies that there exists some absolute "base
URI" against which the relative reference is applied. Indeed, the
base URI is necessary to define the semantics of any relative URI
reference; without it, a relative reference is meaningless. In order
for relative URI to be usable within a document, the base URI of that
document must be known to the parser.
C. Examples of Resolving Relative URI References
Within an object with a well-defined base URI of
http://a/b/c/d;p?q
the relative URI would be resolved as follows:
C.1. Normal Examples
g:h = g:h
g = http://a/b/c/g
./g = http://a/b/c/g
g/ = http://a/b/c/g/
/g = http://a/g
//g = http://g
?y = http://a/b/c/?y
g?y = http://a/b/c/g?y
#s = (current document)#s
g#s = http://a/b/c/g#s
g?y#s = http://a/b/c/g?y#s
;x = http://a/b/c/;x
g;x = http://a/b/c/g;x
g;x?y#s = http://a/b/c/g;x?y#s
. = http://a/b/c/
./ = http://a/b/c/
.. = http://a/b/
../ = http://a/b/
../g = http://a/b/g
../.. = http://a/
../../ = http://a/
../../g = http://a/g
More information about the Squeak-dev
mailing list
|