cleanup flask paths with trailing slashes.
This commit is contained in:
parent
a7938ed9ec
commit
eba9033cc9
@ -74,6 +74,10 @@ def convert_regex_to_flask_path(url_path):
|
||||
return '<regex("{0}"):{1}>'.format(match_pattern, match_name)
|
||||
|
||||
url_path = re.sub("\(\?P<(.*?)>(.*?)\)", caller, url_path)
|
||||
|
||||
if url_path.endswith("/?"):
|
||||
# Flask does own handling of trailing slashes
|
||||
url_path = url_path.rstrip("/?")
|
||||
return url_path
|
||||
|
||||
|
||||
|
@ -21,23 +21,23 @@ def test_s3_server_bucket_create():
|
||||
backend = server.create_backend_app("s3bucket_path")
|
||||
test_client = backend.test_client()
|
||||
|
||||
res = test_client.put('/foobar/', 'http://localhost:5000')
|
||||
res = test_client.put('/foobar', 'http://localhost:5000')
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
res = test_client.get('/')
|
||||
res.data.should.contain(b'<Name>foobar</Name>')
|
||||
|
||||
res = test_client.get('/foobar/', 'http://localhost:5000')
|
||||
res = test_client.get('/foobar', 'http://localhost:5000')
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.contain(b"ListBucketResult")
|
||||
|
||||
res = test_client.get('/missing-bucket/', 'http://localhost:5000')
|
||||
res = test_client.get('/missing-bucket', 'http://localhost:5000')
|
||||
res.status_code.should.equal(404)
|
||||
|
||||
res = test_client.put('/foobar/bar/', 'http://localhost:5000', data='test value')
|
||||
res = test_client.put('/foobar/bar', 'http://localhost:5000', data='test value')
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
res = test_client.get('/foobar/bar/', 'http://localhost:5000')
|
||||
res = test_client.get('/foobar/bar', 'http://localhost:5000')
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.equal(b"test value")
|
||||
|
||||
@ -46,14 +46,14 @@ def test_s3_server_post_to_bucket():
|
||||
backend = server.create_backend_app("s3bucket_path")
|
||||
test_client = backend.test_client()
|
||||
|
||||
res = test_client.put('/foobar2/', 'http://localhost:5000/')
|
||||
res = test_client.put('/foobar2', 'http://localhost:5000/')
|
||||
res.status_code.should.equal(200)
|
||||
|
||||
test_client.post('/foobar2/', "https://localhost:5000/", data={
|
||||
test_client.post('/foobar2', "https://localhost:5000/", data={
|
||||
'key': 'the-key',
|
||||
'file': 'nothing'
|
||||
})
|
||||
|
||||
res = test_client.get('/foobar2/the-key/', 'http://localhost:5000/')
|
||||
res = test_client.get('/foobar2/the-key', 'http://localhost:5000/')
|
||||
res.status_code.should.equal(200)
|
||||
res.data.should.equal(b"nothing")
|
||||
|
Loading…
Reference in New Issue
Block a user