tjwalch/django-livereload-server

`livereload_script` should use "protocol-relative URL"

Opened this issue · 2 comments

nulty commented

Description

def livereload_script():
if settings.DEBUG:
return format_html(
"""<script src="{}:{}/livereload.js"></script>""",

When this loads in my browser, the src populated with a relative URL path. The browser interprets this with the expectation that the path should be appended to the pages current URL.

The result is http://localhost:8000/127.0.0.1:35729/livereload.js which isn't going to work.

Proposal

By adding the relative protocol syntax, the browser can interpret the script src as a complete URI with an empty scheme. The scheme is inherited from the pages scheme.

 """<script src="//{}:{}/livereload.js"></script>""", 

Links

Protocol Relative URL

nulty commented

This is actually addressed in #61

@nulty I don't think it was addressed. The change in #61 specifies the protocol to http. I like your proposal better.