fix(xo-remote-parser): correctly handle empty S3 region

Introduced by c219ea0
This commit is contained in:
Florent Beauchamp 2022-09-30 16:49:59 +02:00 committed by Julien Fontanet
parent c964a1471a
commit ab9428a9c4
3 changed files with 14 additions and 1 deletions

View File

@ -23,6 +23,7 @@
<!--packages-start-->
- xo-remote-parser patch
- xo-server-transport-nagios patch
<!--packages-end-->

View File

@ -71,7 +71,7 @@ export const parse = string => {
const parsed = urlParser(string, false)
object.protocol = parsed.protocol === 's3:' ? 'https' : 'http'
object.type = 's3'
object.region = parsed.hash.length === 0 ? undefined : parsed.hash.slice(1) // remove '#'
object.region = parsed.hash.length < 2 ? undefined : parsed.hash.slice(1) // remove '#'
object.host = parsed.host
object.path = parsed.pathname
object.username = parsed.username

View File

@ -171,6 +171,18 @@ const parseData = deepFreeze({
allowUnauthorized: true,
},
},
's3 with empty region ': {
string: 's3://AKIAS:XSuBupZ0mJlu%2B@s3-us-west-2.amazonaws.com/test-bucket/dir#',
object: {
type: 's3',
protocol: 'https',
host: 's3-us-west-2.amazonaws.com',
path: '/test-bucket/dir',
username: 'AKIAS',
password: 'XSuBupZ0mJlu+',
region: undefined,
},
},
})
const formatData = deepFreeze({