forked from MapComplete/MapComplete
chore: automated housekeeping...
This commit is contained in:
parent
c10fecb7e8
commit
f5d7686c98
234 changed files with 3493 additions and 2482 deletions
|
|
@ -13,12 +13,10 @@ export default class UrlValidator extends Validator {
|
|||
"tripadvisor.co.uk",
|
||||
"tripadvisor.com.au",
|
||||
"katestravelexperience.eu",
|
||||
"hoteldetails.eu"
|
||||
"hoteldetails.eu",
|
||||
])
|
||||
|
||||
private static readonly discouragedWebsites = new Set<string>([
|
||||
"facebook.com"
|
||||
])
|
||||
private static readonly discouragedWebsites = new Set<string>(["facebook.com"])
|
||||
|
||||
constructor(name?: string, explanation?: string, forceHttps?: boolean) {
|
||||
super(
|
||||
|
|
@ -93,14 +91,10 @@ export default class UrlValidator extends Validator {
|
|||
* v.getFeedback("https://booking.com/some-hotel.html").textFor("en") // => Translations.t.validation.url.spamSite.Subs({host: "booking.com"}).textFor("en")
|
||||
*/
|
||||
getFeedback(s: string, getCountry?: () => string): Translation | undefined {
|
||||
if (
|
||||
!s.startsWith("http://") &&
|
||||
!s.startsWith("https://") &&
|
||||
!s.startsWith("http:")
|
||||
) {
|
||||
if (!s.startsWith("http://") && !s.startsWith("https://") && !s.startsWith("http:")) {
|
||||
s = "https://" + s
|
||||
}
|
||||
try{
|
||||
try {
|
||||
const url = new URL(s)
|
||||
let host = url.host.toLowerCase()
|
||||
if (host.startsWith("www.")) {
|
||||
|
|
@ -112,9 +106,7 @@ export default class UrlValidator extends Validator {
|
|||
if (UrlValidator.discouragedWebsites.has(host)) {
|
||||
return Translations.t.validation.url.aggregator.Subs({ host })
|
||||
}
|
||||
|
||||
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
// pass
|
||||
}
|
||||
const upstream = super.getFeedback(s, getCountry)
|
||||
|
|
@ -122,7 +114,6 @@ export default class UrlValidator extends Validator {
|
|||
return upstream
|
||||
}
|
||||
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
|
|
@ -131,7 +122,6 @@ export default class UrlValidator extends Validator {
|
|||
* v.isValid("https://booking.com/some-hotel.html") // => false
|
||||
*/
|
||||
isValid(str: string): boolean {
|
||||
|
||||
try {
|
||||
if (
|
||||
!str.startsWith("http://") &&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue