Skip to content

Commit 86e6039

Browse files
If subscribed to a container then dont pub twice
1 parent 6ba0869 commit 86e6039

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

index.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,37 @@ module.exports = function attachToServer (server, app, opts) {
1010
app.post('/*', function (req, res, next) {
1111
debug('pub ' + req.originalUrl + ' after post')
1212
solidWs.publish(req.originalUrl)
13-
solidWs.publish(path.dirname(req.originalUrl) + path.sep)
13+
var parent = path.dirname(req.originalUrl) + path.sep
14+
if (parent !== req.originalUrl) {
15+
solidWs.publish(parent)
16+
}
1417
next()
1518
})
1619
app.patch('/*', function (req, res, next) {
1720
debug('pub ' + req.originalUrl + ' after patch')
1821
solidWs.publish(req.originalUrl)
19-
solidWs.publish(path.dirname(req.originalUrl) + path.sep)
22+
var parent = path.dirname(req.originalUrl) + path.sep
23+
if (parent !== req.originalUrl) {
24+
solidWs.publish(parent)
25+
}
2026
next()
2127
})
2228
app.put('/*', function (req, res, next) {
2329
debug('pub ' + req.originalUrl + ' after put')
2430
solidWs.publish(req.originalUrl)
25-
solidWs.publish(path.dirname(req.originalUrl) + path.sep)
31+
var parent = path.dirname(req.originalUrl) + path.sep
32+
if (parent !== req.originalUrl) {
33+
solidWs.publish(parent)
34+
}
2635
next()
2736
})
2837
app.delete('/*', function (req, res, next) {
2938
debug('pub ' + req.originalUrl + ' after delete')
3039
solidWs.publish(req.originalUrl)
31-
solidWs.publish(path.dirname(req.originalUrl) + path.sep)
40+
var parent = path.dirname(req.originalUrl) + path.sep
41+
if (parent !== req.originalUrl) {
42+
solidWs.publish(parent)
43+
}
3244
next()
3345
})
3446
}

0 commit comments

Comments
 (0)