Problem with a protocol creation


#1

Hello everyone,

For a project, I have to create a bower protocol who shall be a shortcut to file.

Example: bower://jquery/dist/jquery.min.js is equivalent to file://…/…/…/app/bower_components/jquery/dist/jquery.min.js

Here is my code :

My problem is : at the top of one of the bower’s files I have a relative link towards another bower’s file ("… /another/file") unfortunately my custom protocol does not seem to understand("…").

Example:
bower://iron-input/iron-input.html contains …/polymer/polymer.html and nevertheless the asked page is bower://iron-input/polymer/polymer.html

Thank you for your help


#2

You strip the first characters off the URL, under the assumption that the URL starts with “bower://”. But what if the URL starts with “…”?

Maybe you can add some logging or use a debugger to see what is the URL when the function is invoked on a relative URL.


#3

Hi, thanks for the answer.

I’ve already tried the console.log on the url retrieve in the protocol handler and it seems that the “…” are just skipped without any reason.

Valère


#4

I have another idea. Well, it’s more a stab in the dark.

How about you use URLs of the form bower://localhost/iron-input/iron-input.html?
Note how HTTP has the hostname in that position (after :// and before the next /).
Note how the file protocol uses extra slashes even though that portion of the URL is empty: file:///foo/bar.