move ea3id

This commit is contained in:
zkldi
2021-05-25 18:18:40 +01:00
parent c9efa57150
commit c52cf36adf
5 changed files with 22 additions and 23 deletions
@@ -4,7 +4,7 @@ import ScoreImportFatalError from "../../../framework/score-importing/score-impo
import { FormatPrError, optNull } from "../../../../utils/prudence";
import { FervidexContext, FervidexScore } from "./types";
import { ConverterIRFervidex } from "./converter";
import { ParseEA3SoftID } from "../../../../utils/util";
import { ParseEA3SoftID } from "../../../../utils/ea3id";
import {
EXT_HEROIC_VERSE,
MODEL_IIDX,
@@ -1,7 +1,7 @@
import { Router, RequestHandler } from "express";
import { UpdateClassIfGreater } from "../../../../utils/class";
import { GetUserWithIDGuaranteed } from "../../../../utils/user";
import { ParseEA3SoftID } from "../../../../utils/util";
import { ParseEA3SoftID } from "../../../../utils/ea3id";
import { EXT_HEROIC_VERSE, MODEL_INFINITAS_2, REV_2DXBMS } from "../../../../constants/ea3id";
import { RequireLoggedIn } from "../../../middleware/require-logged-in";
import { ExpressWrappedScoreImportMain } from "../../../../score-import/framework/express-wrapper";
+1 -1
View File
@@ -52,7 +52,7 @@ app.use(express.json({ limit: "1mb" }));
import mainRouter from "./router/router";
app.use("/", apiRouter);
app.use("/", mainRouter);
/**
* If any user gets to this point, we send them index.html and let react router do the routing (and 404ing)
+19
View File
@@ -0,0 +1,19 @@
export function ParseEA3SoftID(ver: string) {
const a = ver.split(":");
if (a.length !== 5) {
throw new Error(`Invalid Version Code. Had ${a.length} components.`);
}
if (!ver.match(/^[A-Z0-9]{3}:[A-Z]:[A-Z]:[A-Z]:[0-9]{10}$/u)) {
throw new Error(`Invalid Version Code.`);
}
return {
model: a[0],
dest: a[1], // region
spec: a[2],
rev: a[3],
ext: a[4],
};
}
-20
View File
@@ -15,26 +15,6 @@ export function EscapeStringRegexp(string: string) {
return string.replace(/[|\\{}()[\]^$+*?.]/gu, "\\$&").replace(/-/gu, "\\x2d");
}
export function ParseEA3SoftID(ver: string) {
const a = ver.split(":");
if (a.length !== 5) {
throw new Error(`Invalid Version Code. Had ${a.length} components.`);
}
if (!ver.match(/^[A-Z0-9]{3}:[A-Z]:[A-Z]:[A-Z]:[0-9]{10}$/u)) {
throw new Error(`Invalid Version Code.`);
}
return {
model: a[0],
dest: a[1], // region
spec: a[2],
rev: a[3],
ext: a[4],
};
}
/**
* Takes a process.hrtime.bigint(), and returns the miliseconds elapsed since it.
* This function will not work if more than 100(ish) days have passed since the first reference.