diff --git a/hermes-console/src/composables/subscription/use-subscription-filters-debug/useSubscriptionFiltersDebug.ts b/hermes-console/src/composables/subscription/use-subscription-filters-debug/useSubscriptionFiltersDebug.ts index 43bc147515..83fa40cb3b 100644 --- a/hermes-console/src/composables/subscription/use-subscription-filters-debug/useSubscriptionFiltersDebug.ts +++ b/hermes-console/src/composables/subscription/use-subscription-filters-debug/useSubscriptionFiltersDebug.ts @@ -1,15 +1,15 @@ import { ContentType } from '@/api/content-type'; import { dispatchErrorNotification } from '@/utils/notification-utils'; +import type { FetchTopicContentType } from '@/composables/topic/use-topic/useTopic'; import { fetchContentType } from '@/composables/topic/use-topic/useTopic'; +import type { Ref } from 'vue'; import { ref } from 'vue'; import { useGlobalI18n } from '@/i18n'; import { useNotificationsStore } from '@/store/app-notifications/useAppNotifications'; import { VerificationStatus } from '@/api/message-filters-verification'; import { verifyFilters } from '@/api/hermes-client'; -import type { FetchTopicContentType } from '@/composables/topic/use-topic/useTopic'; import type { PathFilter } from '@/views/subscription/subscription-form/subscription-basic-filters/types'; import type { PathFilterJson } from '@/api/subscription'; -import type { Ref } from 'vue'; export interface UseSubscriptionFiltersDebug { status: Ref; @@ -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 = ref(); @@ -52,7 +61,7 @@ export function useSubscriptionFiltersDebug(): UseSubscriptionFiltersDebug { ); const response = ( await verifyFilters(topicName, { - message: btoa(message), + message: b64EncodeUnicode(message), filters: filtersJSON, }) ).data;