Skip to content

Commit

Permalink
add support for debugging filters with all unicode characters
Browse files Browse the repository at this point in the history
  • Loading branch information
moscicky committed Apr 30, 2024
1 parent 6dd3829 commit bb5b6ea
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ const toFiltersJSON = (
};
};

// https://stackoverflow.com/a/30106551
function b64EncodeUnicode(str: string): string {
return btoa(
encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function (match, p1) {

Check failure on line 41 in hermes-console/src/composables/subscription/use-subscription-filters-debug/useSubscriptionFiltersDebug.ts

View workflow job for this annotation

GitHub Actions / build

Delete `··`

Check failure on line 41 in hermes-console/src/composables/subscription/use-subscription-filters-debug/useSubscriptionFiltersDebug.ts

View workflow job for this annotation

GitHub Actions / build

Delete `··`
return String.fromCharCode(parseInt(p1, 16));

Check failure on line 42 in hermes-console/src/composables/subscription/use-subscription-filters-debug/useSubscriptionFiltersDebug.ts

View workflow job for this annotation

GitHub Actions / build

Delete `··`

Check failure on line 42 in hermes-console/src/composables/subscription/use-subscription-filters-debug/useSubscriptionFiltersDebug.ts

View workflow job for this annotation

GitHub Actions / build

Delete `··`
}),

Check failure on line 43 in hermes-console/src/composables/subscription/use-subscription-filters-debug/useSubscriptionFiltersDebug.ts

View workflow job for this annotation

GitHub Actions / build

Delete `··`

Check failure on line 43 in hermes-console/src/composables/subscription/use-subscription-filters-debug/useSubscriptionFiltersDebug.ts

View workflow job for this annotation

GitHub Actions / build

Delete `··`
);
}

export function useSubscriptionFiltersDebug(): UseSubscriptionFiltersDebug {
const notificationStore = useNotificationsStore();
const status: Ref<VerificationStatus | undefined> = ref();
Expand All @@ -52,7 +61,7 @@ export function useSubscriptionFiltersDebug(): UseSubscriptionFiltersDebug {
);
const response = (
await verifyFilters(topicName, {
message: btoa(message),
message: b64EncodeUnicode(message),
filters: filtersJSON,
})
).data;
Expand Down

0 comments on commit bb5b6ea

Please sign in to comment.