Skip to content

Commit

Permalink
fix: do not throw when failing to decode URI
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanshatford committed Apr 8, 2024
1 parent 19f638b commit acfc19a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/kind-countries-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hey-api/openapi-ts": patch
---

fix: do not throw when failing to decode URI
6 changes: 5 additions & 1 deletion packages/openapi-ts/src/compiler/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ const blankSourceFile = createSourceFile('');
*/
export function tsNodeToString(node: ts.Node): string {
const result = printer.printNode(ts.EmitHint.Unspecified, node, blankSourceFile);
return decodeURIComponent(result);
try {
return decodeURIComponent(result);
} catch {
return result;
}

Check warning on line 30 in packages/openapi-ts/src/compiler/utils.ts

View check run for this annotation

Codecov / codecov/patch

packages/openapi-ts/src/compiler/utils.ts#L29-L30

Added lines #L29 - L30 were not covered by tests
}

// ots for openapi-ts is helpers to reduce repetition of basic ts factory functions.
Expand Down

0 comments on commit acfc19a

Please sign in to comment.