|
| 1 | +const assert = require('assert'); |
| 2 | +const chromestub = require('./chrome-stub.js'); |
| 3 | + |
| 4 | +describe('getHost', () => { |
| 5 | + const redirectors = [ |
| 6 | + { browser: 'chrome', module: require('../testee/chrome.js') }, |
| 7 | + { browser: 'edge', module: require('../testee/edge.js') }, |
| 8 | + ].forEach(({browser, module}) => { |
| 9 | + describe(browser, () => { |
| 10 | + const redirector = module.redirector; |
| 11 | + it('http: extract host name', () => { |
| 12 | + const url = 'http://www.google.com/'; |
| 13 | + assert.equal(redirector._getHost(url), 'www.google.com'); |
| 14 | + }); |
| 15 | + it('https: extract host name', () => { |
| 16 | + const url = 'https://www.google.com/'; |
| 17 | + assert.equal(redirector._getHost(url), 'www.google.com'); |
| 18 | + }); |
| 19 | + it('exclude account', () => { |
| 20 | + const url = 'https://foobar:password@www.google.com/'; |
| 21 | + assert.equal(redirector._getHost(url), 'www.google.com'); |
| 22 | + }); |
| 23 | + // TODO: |
| 24 | + // Although C++ implementation intends to exclude port number, JavaScript |
| 25 | + // one includes it. So that this test always fails with current code. |
| 26 | + // We may need to fix it. |
| 27 | + it('exclude port number' /*, () => { |
| 28 | + const url = 'https://www.google.com:8080/'; |
| 29 | + assert.equal(redirector._getHost(url), 'www.google.com'); |
| 30 | + }*/); |
| 31 | + }); |
| 32 | + }); |
| 33 | +}); |
0 commit comments