Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6656627
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:40:01+00:00 2026-05-26T01:40:01+00:00

Python has a function urljoin that takes two URLs and concatenates them intelligently. Is

  • 0

Python has a function urljoin that takes two URLs and concatenates them intelligently. Is there a library that provides a similar function in AS3?

urljoin documentation: http://docs.python.org/library/urlparse.html

And python example:

>>> urljoin('http://www.cwi.nl/doc/Python.html', '../res/jer.png')
'http://www.cwi.nl/res/jer.png'

I want to know if there is an implementation of urljoin function, not the whole urlparse package

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:40:01+00:00Added an answer on May 26, 2026 at 1:40 am

    Some raw code doing what you want, so you can skip all of the bloated libraries:

    var urlJoin:Function = function(base:String, relative:String):String
    {
        // See if there is already a protocol on this
        if (relative.indexOf("://") != -1)
            return relative;
    
        // See if this is protocol-relative
        if (relative.indexOf("//") == 0)
        {
            var protocolIndex:int = base.indexOf("://");
            return base.substr(0, protocolIndex+1) + relative;
        }
    
        // We need to split the domain and the path for the remaining options
        var protocolIndexEnd:int = base.indexOf("://") + 3;
        if (base.indexOf("/", protocolIndexEnd) == -1) // append slash if passed only http://bla.com
            base += "/";
        var endDomainIndex:int = base.indexOf("/", protocolIndexEnd);
        var domain:String = base.substr(0, endDomainIndex);
        var path:String = base.substr(endDomainIndex);
        if (path.lastIndexOf("/") != path.length-1) // trim off any ending file name
            path = path.substr(0, path.lastIndexOf("/")+1);
    
        // See if this is site-absolute
        if (relative.indexOf("/") == 0)
        {
            return domain + relative;
        }
    
        // See if this is document-relative with ../
        while (relative.indexOf("../") == 0)
        {
            relative = relative.substr(3);
            if (path.length > 1)
            {
                var secondToLastSlashIndex:int = path.substr(0, path.length-1).lastIndexOf("/");
                path = path.substr(0, secondToLastSlashIndex+1);
            }
        }   
        // Finally, slap on whatever ending is left
        return domain + path + relative;
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Python has a function urljoin that takes two URLs and concatenates them intelligently. Is
I know that python has a len() function that is used to determine the
Python has a nice zip() function. Is there a PHP equivalent?
Is there a built-in function in Python that would replace (or remove, whatever) the
is there a python editor has autocompletion function in imported module ? i think
I have a simple class in python that has a __str__() function. Like this:
Python has a flag -O that you can execute the interpreter with. The option
If you are relying on an implementation of Python that has a Global Interpreter
Python has a built in function sum , which is effectively equivalent to: def
Does anyone know if Python has an in-built function to work to print out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.