Make a relative url path from an absolute path to another one

Discussion in 'Python' started by Thomas Guettler, Oct 27, 2003.

  1. Am Mon, 27 Oct 2003 15:18:38 +0100 schrieb Gilles Lenfant:

    > Hi,
    >
    > I'm sometimes brain dead for a simple problem like this one :
    >
    > Given an origin absolute URL and a destination absolute URL, I want to make
    > a relative path from the origin to the destination.


    I did this some time ago:
    http://guettli.sourceforge.net/gthumpy/src/relative_url.py

    Hope that helps,
    Thomas
     
    Thomas Guettler, Oct 27, 2003
    #1
    1. Advertising

  2. Gilles Lenfant, Oct 27, 2003
    #2
    1. Advertising

  3. "Thomas Guettler" <> a écrit dans le message de
    news: ...
    > Am Mon, 27 Oct 2003 15:18:38 +0100 schrieb Gilles Lenfant:
    >
    > > Hi,
    > >
    > > I'm sometimes brain dead for a simple problem like this one :
    > >
    > > Given an origin absolute URL and a destination absolute URL, I want to

    make
    > > a relative path from the origin to the destination.

    >
    > I did this some time ago:
    > http://guettli.sourceforge.net/gthumpy/src/relative_url.py
    >
    > Hope that helps,
    > Thomas
    >


    It helped of course (it's exactly what I needed)

    Many thanks Thomas

    --
    Gilles
     
    Gilles Lenfant, Oct 27, 2003
    #3
  4. Thomas Guettler

    Andrei Guest

    Gilles Lenfant wrote on Mon, 27 Oct 2003 15:18:38 +0100:

    > I'm sometimes brain dead for a simple problem like this one :
    >
    > Given an origin absolute URL and a destination absolute URL, I want to make
    > a relative path from the origin to the destination.
    >
    > e.g
    >
    > origin = http://www.stuff.com/x/y/foo.html
    > destination = http://www.stuff.com/x/bar.html


    You could split the strings at every "/" and compare the items of the two
    resulting lists until two unidentical items are found. Then you've found
    the common bit and the different bit and it's not that hard to make a
    relative link for that.

    --
    Yours,

    Andrei

    =====
    Mail address in header catches spam. Real contact info (decode with rot13):
    . Fcnz-serr! Cyrnfr qb abg hfr va choyvp cbfgf. V
    ernq gur yvfg, fb gurer'f ab arrq gb PP.
     
    Andrei, Oct 27, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wl
    Replies:
    1
    Views:
    4,479
  2. =?Utf-8?B?UGF1bCBCb25mYW50aQ==?=

    Response.Redirect() converts relative URL to absolute URL

    =?Utf-8?B?UGF1bCBCb25mYW50aQ==?=, Apr 24, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    6,313
    bruce barker \(sqlwork.com\)
    Apr 25, 2006
  3. Rudi Ahlers
    Replies:
    11
    Views:
    863
    Aaron Bertrand [MVP]
    Apr 11, 2004
  4. James Byrne
    Replies:
    3
    Views:
    625
    James Byrne
    Sep 14, 2010
  5. John Nagle

    Relative URL to an absolute URL?

    John Nagle, Feb 26, 2008, in forum: Javascript
    Replies:
    3
    Views:
    246
    John Nagle
    Feb 26, 2008
Loading...

Share This Page