From a2219964ab96097c3c56ad0fbe62b9c2662b42e8 Mon Sep 17 00:00:00 2001 From: "David A. Wheeler" Date: Wed, 29 Jan 2025 20:32:21 -0500 Subject: [PATCH] Lab redos: Move answers to shared JavaScript We're removing the YAML and moving the answers to a shared JavaScript so that we can easily internationalize (and remove a library we don't really need). I believe this is the last one. Signed-off-by: David A. Wheeler --- docs/labs/redos.html | 13 ------------- docs/labs/redos.js | 17 ++++++++++++++++- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/docs/labs/redos.html b/docs/labs/redos.html index 084851b6..ed5d5243 100644 --- a/docs/labs/redos.html +++ b/docs/labs/redos.html @@ -12,19 +12,6 @@ - - - - - - - diff --git a/docs/labs/redos.js b/docs/labs/redos.js index eaa197e1..1d07145d 100644 --- a/docs/labs/redos.js +++ b/docs/labs/redos.js @@ -71,5 +71,20 @@ info = present: String.raw`\[0-9[Aa]-[Zz]\]`, text: "It's conventional to list letters first, so use [A-Z0-9] not [0-9A-Z]" } - ] + ], + expected: [ + "query('id').isLength({max:50}).matches( /^[A-Z0-9]+$/ ),", + ], + correct: [ + String.raw`\s* query \( + ('id'|"id"|${BACKQUOTE}id${BACKQUOTE}) \) + \. isLength \( \{ max: 50 ,? \} \) + \. matches \( \/\^\[A-Z0-9\]\+\$\/ \) , \s*`, + ], + successes: [ + [ " query ( `id` ) . isLength( {max:50} ).matches( /^[A-Z0-9]+$/ ) , " ], + ], + failures: [ + [ "query('id').isLength({max:50}).matches( /^[A-Z]+$/ ),", ], + ], }