Skip to content

Commit 74978fa

Browse files
committed
Allow period in listen channel names - fix #495
1 parent 0cec331 commit 74978fa

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ function Postgres(a, b) {
176176
return { state: result.state, unlisten }
177177
}
178178

179-
channels[name] = { result: sql`listen ${ sql(name) }`, listeners: [listener] }
179+
channels[name] = { result: sql`listen ${
180+
sql.unsafe('"' + name.replace(/"/g, '""') + '"')
181+
}`, listeners: [listener] }
180182
const result = await channels[name].result
181183
listener.onlisten && listener.onlisten()
182184
return { state: result.state, unlisten }

tests/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,7 +701,7 @@ t('multiple listeners work after a reconnect', async() => {
701701

702702
t('listen and notify with weird name', async() => {
703703
const sql = postgres(options)
704-
const channel = 'wat-;ø§'
704+
const channel = 'wat-;.ø.§'
705705
const result = await new Promise(async r => {
706706
await sql.listen(channel, r)
707707
sql.notify(channel, 'works')

0 commit comments

Comments
 (0)