Skip to content

Commit

Permalink
feat(liveshare): simple url key validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Novout committed Apr 25, 2023
1 parent 66f7993 commit bb4297d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/plugin-multiplayer/src/url.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { PluginTypes } from 'better-write-types'
import { validadeKey } from './utils'

export const UrlKeySet = (
emitter: PluginTypes.PluginEmitter,
Expand All @@ -10,7 +11,7 @@ export const UrlKeySet = (

const key = params?.liveshare

if (key) {
if (validadeKey(key)) {
emitter.emit('plugin-presence-room-join', key)
}
})
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-multiplayer/src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import type { LivesharePresenceItem } from 'better-write-types'
import type { RealtimePresenceState } from '@supabase/supabase-js'

export const validadeKey = (key?: string) => key?.length === 30

export const entries = (state: RealtimePresenceState<LivesharePresenceItem>) =>
Object.entries(state)

Expand Down

0 comments on commit bb4297d

Please sign in to comment.