Skip to content

Commit b33f95b

Browse files
authored
Update functions to sanitize urls to and from the itwin apis (#159)
Fix for [Service Case 1977079](https://dev.azure.com/bentleycs/ProductAdvancement/_workitems/edit/1977079): [CS0618919] Cannot create saved views - Error creating view
1 parent 2cedd46 commit b33f95b

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

.changeset/spotty-places-flow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@itwin/saved-views-client": patch
3+
---
4+
5+
Update sanitization of url strings to include greater than, less than, single and double quotes.

packages/saved-views-client/src/client/ITwinSavedViewsClient.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,21 @@ function replaceAllUrlFields(input: unknown, callback: (value: string) => string
350350
function toITwinApi(url: string): string {
351351
return url
352352
.replaceAll("&", "++and++")
353-
.replaceAll(".", "++dot++");
353+
.replaceAll(".", "++dot++")
354+
.replaceAll("<", "++lst++")
355+
.replaceAll(">", "++gtr++")
356+
.replaceAll("'", "++sqt++")
357+
.replaceAll("\"", "++dqt++");
354358
}
355359

356360
function fromITwinApi(url: string): string {
357361
return url
358362
.replaceAll("++and++", "&")
359-
.replaceAll("++dot++", ".");
363+
.replaceAll("++dot++", ".")
364+
.replaceAll("++lst++", "<")
365+
.replaceAll("++gtr++", ">")
366+
.replaceAll("++sqt++", "'")
367+
.replaceAll("++dqt++", "\"");
360368
}
361369

362370
async function* iteratePagedEndpoint<T extends { _links: HalLinks<["next"?]>; }>(

0 commit comments

Comments
 (0)