fix: 🚑 ketchup pattern

This commit is contained in:
Azalea
2026-04-13 20:42:22 -04:00
parent 2d5fb11dc0
commit 80c088626e
4 changed files with 8 additions and 11 deletions
@@ -71,9 +71,9 @@ ${keychipLines}`.trim(), {
async function addKeychip() {
const rawKeychipId = newKeychip.trim().toUpperCase();
const validRawFormat = /^A\d{14}$/.test(rawKeychipId) || /^A\d{3}-\d{11}$/.test(rawKeychipId);
const validRawFormat = /^([A-Z\d]{4}-[A-Z\d]{11}|[A-Z\d]{15})$/.test(rawKeychipId);
if (!validRawFormat) {
addKeychipError = "Invalid keychip format; use A12345678901234 or A123-12345678901.";
addKeychipError = "Invalid keychip format. Use 15 characters (with optional dash): A12345678901234 or A123-12345678901.";
return;
}
@@ -107,7 +107,7 @@
validate={v => /^https?:\/\/[a-z0-9.-]+(:\d+)?$/i.test(v)} />
<InputTextShort desc={t('trans.field.keychip')} placeholder="e.g. A0299792458"
bind:value={src.keychip} on:change disabled={tested}
validate={v => /^([A-Z0-9]{11}|[A-Z0-9]{4}-[A-Z0-9]{11})$/.test(v)} />
validate={v => /^([A-Z\d]{15}|[A-Z\d]{4}-[A-Z\d]{11})$/.test(v)} />
</div>
<!-- Second input line -->
@@ -241,8 +241,7 @@ class UserRegistrar(
SUCCESS
}
val keychipPattern = Regex("^A\\d{14}$")
val dashedKeychipPattern = Regex("^A\\d{3}-\\d{11}$")
val keychipPattern = Regex("^([A-Z\\d]{4}-[A-Z\\d]{11}|[A-Z\\d]{15})$")
val keychipRange = 1e9.toULong()..1e10.toULong() - 1UL
@@ -252,13 +251,11 @@ class UserRegistrar(
private fun validateCustomKeychip(keychipId: Str): Str {
val raw = keychipId.trim().uppercase()
val normalized = raw.replace("-", "")
val validRawFormat = raw == normalized || dashedKeychipPattern.matches(raw)
if (!validRawFormat || !keychipPattern.matches(normalized))
400 - "Invalid keychip format. Expected A followed by 14 digits (with optional dash)"
if (!keychipPattern.matches(raw))
400 - "Invalid keychip format. Expected 15 or 11 characters (with optional dash)"
return normalized
return raw.replace("-", "")
}
@API("/keychip")
@@ -8,7 +8,7 @@ import icu.samnyan.aqua.sega.allnet.AllNetBillingDecoder
import icu.samnyan.aqua.sega.allnet.AllNetBillingDecoder.decodeAllNetResp
import java.net.URI
val keychipPattern = Regex("([A-Z\\d]{4}-[A-Z\\d]{11}|[A-Z\\d]{11})")
val keychipPattern = Regex("([A-Z\\d]{4}-[A-Z\\d]{11}|[A-Z\\d]{15})")
class AllNetClient(val dns: String, val keychip: String, val game: String, val version: String, val card: String) {
init {