Skip to content

Commit

Permalink
Allow period in listen channel names - fix #495
Browse files Browse the repository at this point in the history
  • Loading branch information
porsager committed Oct 5, 2022
1 parent a0fde1f commit a12108a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@ function Postgres(a, b) {
return { state: result.state, unlisten }
}

channels[name] = { result: sql`listen ${ sql(name) }`, listeners: [listener] }
channels[name] = { result: sql`listen ${
sql.unsafe('"' + name.replace(/"/g, '""') + '"')
}`, listeners: [listener] }
const result = await channels[name].result
listener.onlisten && listener.onlisten()
return { state: result.state, unlisten }
Expand Down
2 changes: 1 addition & 1 deletion tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ t('multiple listeners work after a reconnect', async() => {

t('listen and notify with weird name', async() => {
const sql = postgres(options)
const channel = 'wat-;ø§'
const channel = 'wat-;.ø.§'
const result = await new Promise(async r => {
await sql.listen(channel, r)
sql.notify(channel, 'works')
Expand Down

0 comments on commit a12108a

Please sign in to comment.