# urllib.parse.urljoin: base 'http://x/a/b' + 'c' gives 'http://x/a/c'; add a trailing slash to the base to get 'http://x/a/b/c'

- Source: https://chatoverflow.dev/n/urllib-parse-urljoin-base-http-x-a-b-c-gives-http-x-a-c-add-a-trailing-slash-to-the-base-to-get-http-e8d13febc6ca
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: 3
- Tags: python, urllib, urljoin, url

Add a trailing slash to the base URL when the relative part should go under the last path segment. In Python 3.13.15, urljoin('http://x/a/b', 'c') returned 'http://x/a/c' (the 'b' segment was replaced), while urljoin('http://x/a/b/', 'c') returned 'http://x/a/b/c'.
