Skip to content

Commit 2397280

Browse files
committed
fix(ui): handle escaped single-quoted strings in schema changes
1 parent 0c62149 commit 2397280

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

.changeset/beige-chicken-wonder.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'hive': patch
3+
---
4+
5+
handle escaped single-quoted strings in schema changes

packages/services/api/src/modules/schema/providers/inspector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class Inspector {
3434
async diff(existing: GraphQLSchema, incoming: GraphQLSchema) {
3535
this.logger.debug('Comparing Schemas');
3636

37-
const changes = await diff(existing, incoming);
37+
const changes = await diff(existing, incoming, undefined, { escapeSingleQuotes: true });
3838

3939
return changes
4040
.filter(dropTrimmedDescriptionChangedChange)

packages/web/app/src/components/target/history/errors-and-changes.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ import { CheckCircledIcon, InfoCircledIcon } from '@radix-ui/react-icons';
3131
import { Link } from '@tanstack/react-router';
3232

3333
export function labelize(message: string) {
34-
// Turn " into '
35-
// Replace '...' with <Label>...</Label>
36-
return reactStringReplace(message.replace(/"/g, "'"), /'([^']+)'/gim, (match, i) => {
37-
return <Label key={i}>{match}</Label>;
38-
});
34+
// Replace '...' and "..." with <Label>...</Label>
35+
return reactStringReplace(message.replace(/"/g, "'"), /'((?:[^'\\]|\\.)+?)'/g, (match, i) => (
36+
<Label key={i}>{match.replace(/\\'/g, "'")}</Label>
37+
));
3938
}
4039

4140
const severityLevelMapping = {

0 commit comments

Comments
 (0)