From f68e7283911b62e23c182df796baeb59fe8e68f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E6=9D=89?= Date: Sat, 29 Jul 2017 21:25:29 +0800 Subject: [PATCH 1/2] fix(protocol should include final ":"): sockjs/sockjs-client#395 --- lib/location.js | 2 +- lib/main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/location.js b/lib/location.js index 79a9a9f6..be64fe81 100644 --- a/lib/location.js +++ b/lib/location.js @@ -2,7 +2,7 @@ module.exports = global.location || { origin: 'http://localhost:80' -, protocol: 'http' +, protocol: 'http:' , host: 'localhost' , port: 80 , href: 'http://localhost/' diff --git a/lib/main.js b/lib/main.js index 8a526084..01bb894c 100644 --- a/lib/main.js +++ b/lib/main.js @@ -75,7 +75,7 @@ function SockJS(url, protocols, options) { var secure = parsedUrl.protocol === 'https:'; // Step 2 - don't allow secure origin with an insecure protocol - if (loc.protocol === 'https' && !secure) { + if (loc.protocol === 'https:' && !secure) { throw new Error('SecurityError: An insecure SockJS connection may not be initiated from a page loaded over HTTPS'); } From 9567393edc9d9c098df71465a509249b3edcd1d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=80=E6=9D=89?= Date: Sat, 29 Jul 2017 21:34:11 +0800 Subject: [PATCH 2/2] fix(fix location test for https:): --- tests/lib/main-node.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/main-node.js b/tests/lib/main-node.js index f2695307..87456be6 100644 --- a/tests/lib/main-node.js +++ b/tests/lib/main-node.js @@ -9,7 +9,7 @@ describe('SockJS', function() { describe('WebSocket specification step #2', function () { var main = proxyquire('../../lib/main', { './location': { - protocol: 'https' + protocol: 'https:' }}); var sjs = proxyquire('../../lib/entry', { './main': main });