fix(validation): fix url port validation
This commit is contained in:
Родитель
f73a063ffc
Коммит
3aa84cfe35
|
@ -170,6 +170,13 @@ function isValidUrl(url, hostnameRegex) {
|
|||
// The only trick here is that `new URL()` will add a trailing
|
||||
// slash if there's no path component, which is why we also
|
||||
// compare to `origin` below.
|
||||
|
||||
// if the original url has a :443 in the url we need to strip it for the check below
|
||||
// to follow the `new URL` behaviour.
|
||||
if (/^https:\/\//.test(url) && /:443($|\/[^\d])/.test(url)) {
|
||||
url = url.replace(':443', '')
|
||||
}
|
||||
|
||||
if (parsed.href !== url && parsed.origin !== url) {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -376,9 +376,47 @@ describe('remote device', function () {
|
|||
)
|
||||
|
||||
it(
|
||||
'update device works with callback urls that have ports',
|
||||
'update device works with callback urls that :443 as a port',
|
||||
() => {
|
||||
var goodPushCallback = 'https://updates.push.services.mozilla.com:433'
|
||||
var goodPushCallback = 'https://updates.push.services.mozilla.com:443'
|
||||
var email = server.uniqueEmail()
|
||||
var password = 'test password'
|
||||
return Client.create(config.publicUrl, email, password)
|
||||
.then(
|
||||
function (client) {
|
||||
var deviceInfo = {
|
||||
name: 'test device',
|
||||
type: 'mobile',
|
||||
pushCallback: goodPushCallback,
|
||||
pushPublicKey: '',
|
||||
pushAuthKey: ''
|
||||
}
|
||||
return client.devices()
|
||||
.then(
|
||||
function (devices) {
|
||||
assert.equal(devices.length, 0, 'devices returned no items')
|
||||
return client.updateDevice(deviceInfo)
|
||||
}
|
||||
)
|
||||
.then(
|
||||
function (device) {
|
||||
assert.ok(device.id, 'device.id was set')
|
||||
assert.equal(device.pushCallback, deviceInfo.pushCallback, 'device.pushCallback is correct')
|
||||
}
|
||||
)
|
||||
.catch(
|
||||
function (err) {
|
||||
assert.fail(err, 'request should have worked')
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
)
|
||||
|
||||
it(
|
||||
'update device works with callback urls that a custom port',
|
||||
() => {
|
||||
var goodPushCallback = 'https://updates.push.services.mozilla.com:10332'
|
||||
var email = server.uniqueEmail()
|
||||
var password = 'test password'
|
||||
return Client.create(config.publicUrl, email, password)
|
||||
|
|
Загрузка…
Ссылка в новой задаче