Explorar el Código

fix: model regex captures asterisk suffix (e.g. 5615-96*)

* is not a \w char so trailing \b was cutting it off.
Added [*]? to digit-dash pattern and [-\w*]* to other patterns.
Removed trailing \b so * at end of model is included in the match.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Tony T hace 5 días
padre
commit
159debf9d5
Se han modificado 1 ficheros con 2 adiciones y 2 borrados
  1. 2 2
      server/routers.ts

+ 2 - 2
server/routers.ts

@@ -395,7 +395,7 @@ export const appRouter = router({
             // 5. Stock / inventory
             if (!erpContext && /\b(in stock|available|inventory|stock|availability)\b/.test(msgLower)) {
               // Match model numbers: letter-first (B1234-1) or digit-first (2259W-5, 1436W-6)
-              const modelMatch = msg.match(/\b(\d{3,}(?:-\d+)+|[A-Z]{1,4}\d{2,}[-\w]*|\d{2,}[A-Z]\d*[-\w]*)\b/i);
+              const modelMatch = msg.match(/\b(\d{3,}(?:-\d+[*]?)+|[A-Z]{1,4}\d{2,}[-\w*]*|\d{2,}[A-Z]\d*[-\w*]*)/i);
               if (modelMatch) {
                 erpContext = await lookupStock({ model: modelMatch[1] }, userCtx);
               }
@@ -418,7 +418,7 @@ export const appRouter = router({
 
             // 7. Product images — "show image/photo/picture of [model]" or "image for 1436W-6"
             if (!erpContext && /\b(image|images|photo|photos|picture|pictures|what does .* look like|show me)\b/.test(msgLower)) {
-              const modelMatch = msg.match(/\b(\d{3,}(?:-\d+)+|[A-Z]{1,4}\d{2,}[-\w]*|\d{2,}[A-Z]\d*[-\w]*)\b/i);
+              const modelMatch = msg.match(/\b(\d{3,}(?:-\d+[*]?)+|[A-Z]{1,4}\d{2,}[-\w*]*|\d{2,}[A-Z]\d*[-\w*]*)/i);
               if (modelMatch) {
                 erpContext = await lookupProductImages(modelMatch[1], userCtx);
               }