URI.resolveに注意

Jythonで例を示す。

>>> from java.net import URI

>>> example = URI("http://www.example.com/") 
>>> example.resolve("index.html")
http://www.example.com/index.html

>>> exampleNoPath = URI("http://www.example.com") 
>>> exampleNoPath.resolve("index.html")          
http://www.example.comindex.html

ええー!

>>> uriNoPath = "http://www.example.org"
>>> example = URI(uriNoPath)
>>> if example.path == '':
...         example = URI(uriNoPath + '/')
... 
>>> example.resolve("index.html")
http://www.example.org/index.html

パスが省略されているかチェックする必要がある。