Rewriting urls/requests


#1

I’m currently tinkering around with an app for Electron that, one of the libraries that I’m using links to several other items without specifying the protocol. An example of this would be something like… //code.jquery.com/jquery-1.11.3.min.js instead of http://code.jquery.com/jquery-1.11.3.min.js

Electron interprets this as a local path and prepends file:/ to the path. I’ve been looking at the protocol module and wondering if I can use that to catch these requests and change the protocol to http: instead so that it will load the resources it needs. I know I could dig through the library and fix these but I would have to do that any time that the library got updated. It would be a lot easier to just make it intercept them and rewrite it.

Is this type of behavior possible with protocol module? I’m not really clear on what I can do with it. From what I’m gathering, the way of catching it would be to protocol.interceptFileProtocol() but that that is expecting a file as the output of the handler. Is that correct or could I just do string replacement of the file: with http: and return that?

Any help would be appreciated


#2

Hi, any help on this???