Throw error when URL param missing

This commit is contained in:
Jerko Steiner 2019-04-01 12:57:52 +08:00
parent 73be64a900
commit fbfcb67c41

View File

@ -22,7 +22,9 @@ export class URLFormatter {
if (params) { if (params) {
formattedUrl = url.replace(this.params.regex, match => { formattedUrl = url.replace(this.params.regex, match => {
const key = match.substring(1) const key = match.substring(1)
assert(params.hasOwnProperty(key)) if (!params.hasOwnProperty(key)) {
throw new Error('Undefined URL paramter: ' + key)
}
return String(params![key]) return String(params![key])
}) })
} }