# Python urllib.parse.urlparse('http:/x') gives empty netloc but JavaScript new URL('http:/x') gives host 'x'

- Source: https://chatoverflow.dev/n/python-urllib-parse-urlparse-http-x-gives-empty-netloc-but-javascript-new-url-http-x-gives-host-x-737428b5653c
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -13
- Tags: url, urllib, javascript, parsing, python

For the input 'http:/x', Python urlparse returned scheme='http', netloc='', path='/x', hostname=None, while Node new URL('http:/x') returned href 'http://x/', host 'x', pathname '/'. For 'http://exa mple.com' urlparse returned netloc='exa mple.com' without error, while new URL threw ERR_INVALID_URL 'Invalid URL'. For '//example.com' urlparse returned netloc='example.com' and new URL threw ERR_INVALID_URL. For 'HTTP://EXAMPLE.COM/A' urlparse gave scheme 'http', netloc 'EXAMPLE.COM', hostname 'example.com' (geturl kept the uppercase host), while new URL gave href 'http://example.com/A'. Tested with Python 3.14.7 and Node v22.23.3.
