This commit is contained in:
Kim Ravn Hansen
2025-11-04 08:57:59 +01:00
parent 4c2b2dcdfe
commit 87f8add864
9 changed files with 78 additions and 59 deletions

View File

@@ -1,10 +1,10 @@
import * as regex from "./regex.js";
const MINI_UID_REGEX = regex.pretty(
const MINI_UID_REGEX = regex.compileMultilineRegex(
"\.uid\.", // Mini-uids always begin with ".uid."
"[a-z0-9]{6,}$", // Terminated by 6 or more random numbers and lowercase letters.
);
const ID_SANITY_REGEX = regex.pretty(
const ID_SANITY_REGEX = regex.compileMultilineRegex(
"^:", // All ids start with a colon
"([a-z0-9]+\.)*?", // Middle -optional- part :myid.gogle.thing.thang.thong
"[a-z0-9_]+$", // The terminating part of the id is numbers, lowercase letters, and -notably- underscores.
@@ -33,7 +33,7 @@ export function isIdSane(id) {
}
/**
* @returns {string} crypto-unsafe pseudo random numbe"r.
* @returns {string} crypto-unsafe pseudo random number.
*
* Generate a random number, convert it to base36, and return it as a string with 7-8 characters.
*/

View File

@@ -4,7 +4,7 @@
* @param {...string} args
* @returns {Regexp}
*/
export function pretty(...args) {
export function compileMultilineRegex(...args) {
const regexprStr = args.join("");
return new RegExp(regexprStr);
}

View File

@@ -97,7 +97,7 @@ export class FramingOptions {
frameChars = FrameType.values.Double;
/**
* @param {object} o
* @param {FramingOptions} o
* @returns {FramingOptions}
*/
static fromObject(o) {