analytics.js-integrations icon indicating copy to clipboard operation
analytics.js-integrations copied to clipboard

Force https protocol in load-script when running on file: url (e.g., Electron)

Open srubin opened this issue 3 years ago • 0 comments

The AppCues integration (and a few others) use the loadScript with a protocol relative url:

https://github.com/segmentio/analytics.js-integrations/blob/master/integrations/appcues/lib/index.js#L51

This sets the protocol to http if running loading via a file: url.

https://github.com/segmentio/load-script/blob/master/index.js#L27-L33

We are loading Segment into an Electron app, which loads pages via a file: url. However, we do not want to allow non-https external connections.

Is there a way around this? One idea would be to change the logic in loadScript to default to https instead of http in the file: url case.

srubin avatar Feb 03 '21 18:02 srubin