Skip to content

Commit

Permalink
Fix parse message
Browse files Browse the repository at this point in the history
  • Loading branch information
teodorus-nathaniel committed Mar 8, 2024
1 parent 1986a99 commit 6ee051b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/components/profile-selector/MyAccountMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ const MyAccountDrawerContext = createContext<MyAccountSectionContextState>(initV
export const useMyAccountDrawer = () => useContext(MyAccountDrawerContext)

function parseMessage(data: string) {
const [origin, name, value] = data.split(':')
const match = data.match(/^([^:]+):([^:]+):(.+)$/)
if (!match) return null

const origin = match[1]
const name = match[2]
const value = match[3]
if (origin !== 'grill') return null
return { name: name ?? '', value: value ?? '' }
}
Expand Down

0 comments on commit 6ee051b

Please sign in to comment.