Browse Source

Fix duplicate slashes

master
JustAnotherArchivist 4 years ago
parent
commit
b38349e91f
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      s3-bucket-list

+ 2
- 2
s3-bucket-list View File

@@ -43,7 +43,7 @@ while i < len(sys.argv):
assert len(args) == 1, 'Need one argument: bucket URL' assert len(args) == 1, 'Need one argument: bucket URL'
baseUrl = args[0] baseUrl = args[0]
assert baseUrl.startswith('http://') or baseUrl.startswith('https://'), 'Argument does not look like an HTTP URL' assert baseUrl.startswith('http://') or baseUrl.startswith('https://'), 'Argument does not look like an HTTP URL'
if '/' not in baseUrl.split('://', 1)[1]:
if '/' not in baseUrl.split('://', 1)[1] or not baseUrl.endswith('/'):
baseUrl = f'{baseUrl}/' baseUrl = f'{baseUrl}/'
hostname = baseUrl.split('://', 1)[1].split('/', 1)[0] hostname = baseUrl.split('://', 1)[1].split('/', 1)[0]


@@ -83,7 +83,7 @@ while True:
contents[-1] = contents[-1][:-len('</ListBucketResult>')] contents[-1] = contents[-1][:-len('</ListBucketResult>')]
for content in contents[1:]: for content in contents[1:]:
key = content[5 : content.index(b'</Key>')].decode('utf-8') # 5 = len(b'<Key>') key = content[5 : content.index(b'</Key>')].decode('utf-8') # 5 = len(b'<Key>')
url = f'{baseUrl}/{urllib.parse.quote(key)}'
url = f'{baseUrl}{urllib.parse.quote(key)}'


tags = content.split(b'>') tags = content.split(b'>')
assert len(tags) % 2 == 0 assert len(tags) % 2 == 0


Loading…
Cancel
Save