From b4aaf629b44107a44ee0ec9d5b1f0403c1d52f0c Mon Sep 17 00:00:00 2001 From: Jeongho Nam Date: Fri, 14 Jun 2024 02:30:36 +0900 Subject: [PATCH] Upgrade `@nestia/migrate` for special characters' escaping. --- packages/migrate/package.json | 2 +- packages/migrate/src/utils/StringUtil.ts | 8 ++++++++ website/package.json | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/packages/migrate/package.json b/packages/migrate/package.json index 7a7b83625..bbf25d453 100644 --- a/packages/migrate/package.json +++ b/packages/migrate/package.json @@ -1,6 +1,6 @@ { "name": "@nestia/migrate", - "version": "0.13.14", + "version": "0.13.16", "description": "Migration program from swagger to NestJS", "main": "lib/index.js", "typings": "lib/index.d.ts", diff --git a/packages/migrate/src/utils/StringUtil.ts b/packages/migrate/src/utils/StringUtil.ts index 1f30effd0..989875eab 100644 --- a/packages/migrate/src/utils/StringUtil.ts +++ b/packages/migrate/src/utils/StringUtil.ts @@ -61,6 +61,13 @@ export namespace StringUtil { export const escapeNonVariableSymbols = (str: string): string => { for (const [before, after] of VARIABLE_REPLACERS) str = str.split(before).join(after); + for (let i: number = 0; i <= 9; ++i) + if (str[0] === i.toString()) { + str = "_" + str; + break; + } + str = str.trim(); + if (str === "") return "_empty_"; return str; }; } @@ -92,4 +99,5 @@ const VARIABLE_REPLACERS: [string, string][] = [ ["?", "_question_"], [":", "_colon_"], [";", "_semicolon_"], + ["...", "_rest_"], ]; diff --git a/website/package.json b/website/package.json index 7362f766d..775ad84fe 100644 --- a/website/package.json +++ b/website/package.json @@ -23,7 +23,7 @@ "@mui/icons-material": "5.15.6", "@mui/material": "5.15.6", "@mui/system": "5.15.6", - "@nestia/migrate": "^0.13.14", + "@nestia/migrate": "^0.13.16", "@samchon/openapi": "^0.1.22", "@stackblitz/sdk": "^1.9.0", "js-yaml": "^4.1.0",