Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #736 - bug of undefined length problem. #743

Merged
merged 1 commit into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typia",
"version": "4.1.15",
"version": "4.1.16",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions packages/typescript-json/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript-json",
"version": "4.1.15",
"version": "4.1.16",
"description": "Superfast runtime validators with only one line",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
Expand Down Expand Up @@ -68,7 +68,7 @@
},
"homepage": "https://typia.io",
"dependencies": {
"typia": "4.1.15"
"typia": "4.1.16"
},
"peerDependencies": {
"typescript": ">= 4.7.4"
Expand Down
4 changes: 3 additions & 1 deletion src/functional/$string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
*/
export const $string = (str: string): string => {
if (STR_ESCAPE.test(str) === false) return `"${str}"`;
if (str.length > 41) return JSON.stringify(str);

const length: number = str.length;
if (length > 41) return JSON.stringify(str);

let result = "";
let last = -1;
Expand Down
14 changes: 14 additions & 0 deletions test/features/issues/test_issue_long_string_stringify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import typia from "typia";

import { RandomGenerator } from "typia/lib/utils/RandomGenerator";

export const test_issue_long_string_stringify = (): void => {
const str: string = RandomGenerator.string(1000);
const stringified: string = typia.stringify(str);
const decoded: string = JSON.parse(stringified);

if (str !== decoded)
throw new Error(
`Bug on typia.stringify(): failed to stringify long string.`,
);
};
13 changes: 13 additions & 0 deletions test/generated/output/issues/test_issue_long_string_stringify.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import typia from "typia";

import { RandomGenerator } from "typia/lib/utils/RandomGenerator";

export const test_issue_long_string_stringify = (): void => {
const str: string = RandomGenerator.string(1000);
const stringified: string = typia.stringify(str);
const decoded: string = JSON.parse(stringified);
if (str !== decoded)
throw new Error(
`Bug on typia.stringify(): failed to stringify long string.`,
);
};
Loading