audon/audon-fe/src/assets/utils.js

28 wiersze
815 B
JavaScript
Czysty Zwykły widok Historia

2022-12-04 05:19:41 +00:00
import { helpers } from "@vuelidate/validators";
2022-12-08 08:56:29 +00:00
import router from "../router";
2022-12-04 05:19:41 +00:00
2022-12-06 13:20:36 +00:00
export const validators = {
fqdn: helpers.regex(
2023-01-23 12:10:21 +00:00
/^[a-zA-Z]([a-zA-Z0-9-]+[.]?)*[a-zA-Z0-9]$/,
2022-12-06 13:20:36 +00:00
/^([a-zA-Z0-9]{1}[a-zA-Z0-9-]{0,62})(\.[a-zA-Z0-9]{1}[a-zA-Z0-9-]{0,62})*?(\.[a-zA-Z]{1}[a-zA-Z0-9]{0,62})\.?$/
),
2022-12-08 08:56:29 +00:00
};
2022-12-07 05:45:05 +00:00
export function webfinger(user) {
2022-12-10 03:16:43 +00:00
if (!user) return "";
2022-12-08 08:56:29 +00:00
const url = new URL(user.url);
2023-01-23 12:10:21 +00:00
const finger = user.acct.split("@");
return `${finger[0]}@${url.host}`;
2022-12-08 08:56:29 +00:00
}
export function pushNotFound(route) {
router.push({
name: "notfound",
// preserve current path and remove the first char to avoid the target URL starting with `//`
params: { pathMatch: route.path.substring(1).split("/") },
// preserve existing query and hash if any
query: route.query,
hash: route.hash,
});
2022-12-07 05:45:05 +00:00
}