title: How to handle relative protocol URL in Chrome Extension 3rd party library
body: <p>I'm developing a Chrome extension that relies on a 3rd party javascript library. In the library's code, all of the URLs to their resources and API endpoints use relative protocol, like:</p>
  
  <p><code>//blah.com/api/get-the-stuff/</code></p>
  
  <p>The issue is that when calls are made from within the extension, I think the the URL becomes something like:</p>
  
  <p><code>chrome-extension://blah.com/api/get-the-stuff/</code></p>
  
  <p>Obviously this doesn't work. One solution is to alter the 3rd party library to full URLs, like:</p>
  
  <p><code>https://blah.com/api/get-the-stuff/</code></p>
  
  <p>This works, but really it isn't sustainable to maintain a modified version of this lib.
  Is there a way to handle this?  </p>
  
  <p>I think the <a href="https://developer.chrome.com/extensions/webRequest#event-onBeforeRequest" rel="nofollow noreferrer">chrome.webRequest API</a> looks promising for rewriting the URLs before the request sends, but these relative protocol URLs seem to be failing before they trigger a listener on this API.  The requests show up in the network tab of the developer console as:</p>
  
  <p><code>chrome-extension://invalid/</code></p>
  
  <p>Is this a rewrite that Chrome is doing to my 
  <code>chrome-extension://blah.com/api/get-the-stuff/</code> URLs before the request is created?  Do I need to alter my manifest in some way to allow these "bad" URL requests to fire so I can rewrite them?</p>
  
  <p>Or maybe I'm barking up the wrong tree entirely?  </p>