Issue
If you only pass a query-parameter value, it will not join them as expected.
Second argument
The second argument is interpreted as path, so it needs to be a valid
- complete path,
- path segment (may include query-parameter or fragment)
- query (prefixed with
?
- fragment (prefixed with
#
)
See the docs for urljoin
, use the first 2 examples:
from urllib.parse import urljoin
# the complete query-parameter (question-mark, key, value)
urljoin('https://my.comp.com/Online/SendToken?token=','?token=123')
# 'https://my.comp.com/Online/SendToken?token=123'
# the complete path-segment including query
urljoin('https://my.comp.com/Online/SendToken?token=','SendToken?token=123')
# 'https://my.comp.com/Online/SendToken?token=123'
# a fragment (denoted by hash-symbol) will also work, but not desired
urljoin('https://my.comp.com/Online/SendToken?token=','#123')
# 'https://my.comp.com/Online/SendToken?token=#123'
See also Python: confusions with urljoin