Passing a Windows path to urllib.parse.urlparse, without file://, makes it detect the drive as the scheme even it having '\' after the ':', which makes it completelly wrong for a url.
Probably this function shouldn't be used with non-uri paths, but it shouldn't return a result that is so wrong as this. I think at least it should return the same input string if the url doesn't start with ://.
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
from urllib.parse import urlparse
urlparse('M:\\prog\\tests\\python\\json-ref-dict\\tests/schemas/master.yaml')
Out[3]: ParseResult(scheme='m', netloc='', path='\\prog\\tests\\python\\json-ref-dict\\tests/schemas/master.yaml', params='', query='', fragment='')
str(urlparse('M:\\prog\\tests\\python\\json-ref-dict\\tests/schemas/master.yaml'))
Out[4]: "ParseResult(scheme='m', netloc='', path='\\\\prog\\\\tests\\\\python\\\\json-ref-dict\\\\tests/schemas/master.yaml', params='', query='', fragment='')"
urlparse('M:\prog\tests\python\json-ref-dict\\tests/schemas/master.yaml')
Out[5]: ParseResult(scheme='m', netloc='', path='\\prog\tests\\python\\json-ref-dict\\tests/schemas/master.yaml', params='', query='', fragment='')
|