livereload/livereload-js

Question about Options.extract, default port, port 80 and 443

christianpujol opened this issue · 1 comments

There is something that I do not understand on how the port is extracted in Options.extract

How can lrUrlRegexp not capture the default port value?

If the file file is served on the default port 35729 it should appear in both src and srcAttr and be captured by the RegEx ? 

and if no port appears it should mean that livereload.js have been served:

*  on port 80 if the protocol is http.
*  or port  443 if the protocol is https.

for other protocols we can still suppose that the port is the default one.

and in this case why not doing something like :

options.https = element.src.indexOf('https') === 0;
options.http = element.src.indexOf('http') === 0;
options.port = port    ? parseInt(port, 10)
    : portFromAttr
        ? parseInt(portFromAttr, 10)
        : options.https
          ? 443
            options.http
                ? 80
                :options.port;

Or is there some case where the port 35729 could not be appearing in element.src and element.getAttribute('src') ?

smhg commented

Closing because I'm assuming you addressed this issue in #93 and the accompanying PR. Feel free to correct me if I got this wrong.