urlparse http://site.com/../../../page.html

monk.e.boy johng at neutralize.com
Tue Apr 8 06:41:26 EDT 2008


Hi,

  Can anyone help me with the urlparse:

>>> import urlparse
>>> urlparse.urljoin( 'http://site.com/path/', '../../../../path/' )
'http://site.com/../../../path/'
>>> urlparse.urljoin( 'http://site.com/', '../../../../path/' )
'http://site.com/../../../../path/'
>>> urlparse.urljoin( 'http://site.com/', '/path/../path/.././path/./' )
'http://site.com/path/../path/.././path/./'

I'm sure these should all return:

http://site.com/path/

I tested all these in firefox -- I built a page with these links as
anchors and mouse_over them to see what Firefox thinks they should be.
I also know that google parses these URLs into http://site.com/path/
because one of our website has the above links in as a test.

Is this a bug in urlparse? I'm not sure.

Can anyone help me write something that will create the url I want.
Should I look at os.path to help? I would like it to work on both Win
and Linux :-)

thanks

monk.e.boy



More information about the Python-list mailing list