mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-01-31 04:22:25 +01:00
Fix empty path behavior
This commit is contained in:
parent
842bc44214
commit
dd870cefb3
2 changed files with 6 additions and 2 deletions
|
@ -270,6 +270,8 @@ class TestUtil(unittest.TestCase):
|
|||
('C:abc\\..\\', 'C:'),
|
||||
('C:abc\\..\\def\\..\\..\\', 'C:..'),
|
||||
('C:\\abc\\xyz///..\\def\\', 'C:\\abc\\def'),
|
||||
('abc/../', '.'),
|
||||
('./abc/../', '.'),
|
||||
]:
|
||||
result = sanitize_path(test)
|
||||
assert result == expected, f'{test} was incorrectly resolved'
|
||||
|
|
|
@ -703,7 +703,8 @@ def sanitize_path(s, force=False):
|
|||
if not force:
|
||||
return s
|
||||
root = '/' if s.startswith('/') else ''
|
||||
return root + '/'.join(_sanitize_path_parts(s.split('/')))
|
||||
path = '/'.join(_sanitize_path_parts(s.split('/')))
|
||||
return root + path if root or path else '.'
|
||||
|
||||
normed = s.replace('/', '\\')
|
||||
|
||||
|
@ -722,7 +723,8 @@ def sanitize_path(s, force=False):
|
|||
root = '\\' if normed[:1] == '\\' else ''
|
||||
parts = normed.split('\\')
|
||||
|
||||
return root + '\\'.join(_sanitize_path_parts(parts))
|
||||
path = '\\'.join(_sanitize_path_parts(parts))
|
||||
return root + path if root or path else '.'
|
||||
|
||||
|
||||
def sanitize_url(url, *, scheme='http'):
|
||||
|
|
Loading…
Add table
Reference in a new issue