Skip to content
This repository has been archived by the owner on Oct 9, 2018. It is now read-only.

os.path.join() is used for building urls #25

Open
Marm0t opened this issue Aug 29, 2014 · 1 comment
Open

os.path.join() is used for building urls #25

Marm0t opened this issue Aug 29, 2014 · 1 comment

Comments

@Marm0t
Copy link

Marm0t commented Aug 29, 2014

Hello.

As it written in title of this issue os.path.join() is used in someplaces for building urls.
For example in oauth.py:

class OAuth(Namespace):
 [...]
    request_token_url = os.path.join(
        BASE_URL, 'api/auth/v1/oauth/token/request')
    authorize_url = os.path.join(BASE_URL, 'services/api/auth')
    access_token_url = os.path.join(BASE_URL, 'api/auth/v1/oauth/token/access')
 [...]

normally it works fine but for urls os.path.join is not the best either since on Windows systems os.path.join will join using backslash \ which won't be a valid url. As consequence on windows we get exception like this:
Unable to find the server at www.odesk.com\api

Isn't it better to use urlparse.urljoin (and urllib.parse.urljoin for python 3) for this?
Otherwise it should be written somewhere in documentation that Windows is not supported.

Best regards.

@kipanshi
Copy link

kipanshi commented Sep 1, 2014

Actually the use of os.path.join was initially incorrect, as the URI is not the posix path, and
it should be replaced everywhere to

'/'.join(BASE_URL, '/api')

etc.

as the URI always uses slash.
This will be fixed in the next release.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants