Skip to content

Commit a12108a

Browse files
committed
Allow period in listen channel names - fix #495
1 parent a0fde1f commit a12108a

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
@@ -700,7 +700,7 @@ t('multiple listeners work after a reconnect', async() => {
700700

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

0 commit comments

Comments
 (0)