Note
Segment has paused maintenance on this project, but may return it to an active status in the future. Issues and pull requests from external contributors are not being considered, although internal contributions may appear from time to time. The project remains available under its open source license for anyone to use.
Testing component used to fake protocols from the browser. Overrides window.location.protocol
properties with fake ones using Object.defineProperty
, so it won't work on IE8. Probably a good thing to only use in testing.
$ npm install @segment/protocol
Returns the current protocol that the document is using
protocol(); // 'http:'
When supplied with an argument, sets a custom protocol for the document.
protocol('chrome-extension:');
protocol(); // 'chrome-extension:'
Sets the protocol to be http
protocol(); // 'file:'
protocol.http(); // 'http:'
Sets the protocol to be https:
protocol(); // 'file:'
protocol.https(); // 'https:'
Resets the protocol to be whatever it was at page load.
protocol('x:');
protocol.reset();
protocol(); // 'http:'