Merge develop

This commit is contained in:
Pieter Vander Vennet 2023-09-16 19:03:07 +02:00
commit be5f46d8c8
321 changed files with 14942 additions and 4545 deletions

View file

@ -1,13 +1,15 @@
import {Validator} from "../Validator"
import {Translation} from "../../i18n/Translation";
import Translations from "../../i18n/Translations";
import { Validator } from "../Validator"
import { Translation } from "../../i18n/Translation"
import Translations from "../../i18n/Translations"
export default class FediverseValidator extends Validator {
public static readonly usernameAtServer: RegExp = /^@?(\w+)@((\w|\.)+)$/
constructor() {
super("fediverse", "Validates fediverse addresses and normalizes them into `@username@server`-format");
super(
"fediverse",
"Validates fediverse addresses and normalizes them into `@username@server`-format"
)
}
/**
@ -15,8 +17,8 @@ export default class FediverseValidator extends Validator {
* @param s
*/
reformat(s: string): string {
if(!s.startsWith("@")){
s = "@"+s
if (!s.startsWith("@")) {
s = "@" + s
}
if (s.match(FediverseValidator.usernameAtServer)) {
return s
@ -25,39 +27,38 @@ export default class FediverseValidator extends Validator {
const url = new URL(s)
const path = url.pathname
if (path.match(/^\/\w+$/)) {
return `@${path.substring(1)}@${url.hostname}`;
return `@${path.substring(1)}@${url.hostname}`
}
} catch (e) {
// Nothing to do here
}
return undefined
}
getFeedback(s: string): Translation | undefined {
const match = s.match(FediverseValidator.usernameAtServer)
console.log("Match:", match)
if (match) {
const host = match[2]
getFeedback(s: string): Translation | undefined {
const match = s.match(FediverseValidator.usernameAtServer)
console.log("Match:", match)
if (match) {
const host = match[2]
try {
const url = new URL("https://" + host)
return undefined
} catch (e) {
return Translations.t.validation.fediverse.invalidHost.Subs({ host })
}
}
try {
const url = new URL("https://" + host)
return undefined
const url = new URL(s)
const path = url.pathname
if (path.match(/^\/\w+$/)) {
return undefined
}
} catch (e) {
return Translations.t.validation.fediverse.invalidHost.Subs({host})
// Nothing to do here
}
return Translations.t.validation.fediverse.feedback
}
try {
const url = new URL(s)
const path = url.pathname
if (path.match(/^\/\w+$/)) {
return undefined
}
} catch (e) {
// Nothing to do here
}
return Translations.t.validation.fediverse.feedback
}
isValid(s): boolean {
return this.getFeedback(s) === undefined
return this.getFeedback(s) === undefined
}
}

View file

@ -1,7 +1,7 @@
import { Translation } from "../../i18n/Translation"
import Translations from "../../i18n/Translations"
import { Validator } from "../Validator"
import { ValidatorType } from "../Validators";
import { ValidatorType } from "../Validators"
export default class FloatValidator extends Validator {
inputmode: "decimal" = "decimal"