Skip to content

Commit

Permalink
add support for debugging filters with all unicode characters (#1856)
Browse files Browse the repository at this point in the history
  • Loading branch information
moscicky committed May 24, 2024
1 parent 9f8b004 commit 1ebd3e4
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) {
return String.fromCharCode(parseInt(p1, 16));
}),
);
}

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 1ebd3e4

Please sign in to comment.