10000 Parse url and use pathname for prefix matching · sockjs/sockjs-node@b74358b · GitHub
[go: up one dir, main page]

Skip to content

Commit b74358b

Browse files
committed
Parse url and use pathname for prefix matching
Fixes #234
1 parent b991a1d commit b74358b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/server.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict';
22

33
const events = require('events');
4+
const url = require('url');
45
const debug = require('debug')('sockjs:server');
56
const listener = require('./listener');
67
const webjs = require('./webjs');
@@ -41,7 +42,7 @@ class Server extends events.EventEmitter {
4142
if (this.options.prefix) {
4243
// remove trailing slash, but not leading
4344
this.options.prefix = this.options.prefix.replace(/\/$/, '');
44-
this._prefixMatches = (url) => url.startsWith(this.options.prefix);
45+
this._prefixMatches = (requrl) => url.parse(requrl).pathname.startsWith(this.options.prefix);
4546
}
4647

4748
this.options.log('debug', `SockJS v${pkg.version} bound to ${JSON.stringify(this.options.prefix)}`);

0 commit comments

Comments
 (0)
0