mirror of
https://github.com/versia-pub/api.git
synced 2025-12-06 16:38:20 +01:00
41 lines
1,022 B
TypeScript
41 lines
1,022 B
TypeScript
/**
|
|
* Regular expressions for matching various strings.
|
|
* @module federation/schemas/regex
|
|
* @see module:federation/schemas/base
|
|
*/
|
|
|
|
import {
|
|
caseInsensitive,
|
|
charIn,
|
|
createRegExp,
|
|
digit,
|
|
exactly,
|
|
global,
|
|
letter,
|
|
oneOrMore,
|
|
} from "magic-regexp";
|
|
|
|
/**
|
|
* Regular expression for matching emojis.
|
|
*/
|
|
export const emojiRegex: RegExp = createRegExp(
|
|
// A-Z a-z 0-9 _ -
|
|
oneOrMore(letter.or(digit).or(exactly("_")).or(exactly("-"))),
|
|
[caseInsensitive, global],
|
|
);
|
|
|
|
/**
|
|
* Regular expression for matching an extension_type
|
|
* @example org.lysand:custom_emojis/Emoji
|
|
*/
|
|
export const extensionTypeRegex: RegExp = createRegExp(
|
|
// org namespace, then colon, then alphanumeric/_/-, then extension name
|
|
exactly(
|
|
oneOrMore(exactly(letter.lowercase.or(digit).or(charIn("_-.")))),
|
|
exactly(":"),
|
|
oneOrMore(exactly(letter.lowercase.or(digit).or(charIn("_-")))),
|
|
exactly("/"),
|
|
oneOrMore(exactly(letter.or(digit).or(charIn("_-")))),
|
|
),
|
|
);
|