mirror of
https://github.com/comatory/fb2iCal
synced 2025-06-05 22:09:25 +02:00
allow passing FB event number as parameter
This commit is contained in:
26
lib/utils.js
Normal file
26
lib/utils.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const checkValidURL = (url) => {
|
||||
return checkURLFormat(url) ||
|
||||
checkNumberURLParameter(url)
|
||||
}
|
||||
|
||||
const checkURLFormat = (url) => {
|
||||
return /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/.test(url)
|
||||
}
|
||||
|
||||
const checkNumberURLParameter = (url) => {
|
||||
return /^\d+$/.test(url)
|
||||
}
|
||||
|
||||
const createParserError = () => {
|
||||
const err = new Error('Unable to parse event data.')
|
||||
err.statusCode = 422
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
checkValidURL,
|
||||
checkURLFormat,
|
||||
checkNumberURLParameter,
|
||||
createParserError,
|
||||
}
|
Reference in New Issue
Block a user