Skip to content

Commit

Permalink
Merge pull request #49 from SparshithNR/prefix-fix
Browse files Browse the repository at this point in the history
Consider liveReloadPrefix option which got added into tiny-lr
  • Loading branch information
rwjblue committed Jul 23, 2018
2 parents b5d8e21 + 92f52a7 commit 4b6c25a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 4 additions & 1 deletion index.js
@@ -1,5 +1,7 @@
'use strict';

var buildLiveReloadPath = require('clean-base-url');

module.exports = {
name: 'live-reload-middleware',

Expand All @@ -18,10 +20,11 @@ module.exports = {
liveReloadOptions.snipver = 1;
}

var liveReloadPath = buildLiveReloadPath(options.liveReloadPrefix);
return "(function() {\n " +
(liveReloadOptions ? "window.LiveReloadOptions = " + JSON.stringify(liveReloadOptions) + ";\n " : '') +
"var srcUrl = " + (options.liveReloadJsUrl ? "'" + options.liveReloadJsUrl + "'" : "null") + ";\n " +
"var src = srcUrl || ((location.protocol || 'http:') + '//' + (location.hostname || 'localhost') + ':" + options.liveReloadPort + "/livereload.js');\n " +
"var src = srcUrl || ((location.protocol || 'http:') + '//' + (location.hostname || 'localhost') + ':" + options.liveReloadPort + liveReloadPath +"livereload.js');\n " +
"var script = document.createElement('script');\n " +
"script.type = 'text/javascript';\n " +
"script.src = src;\n " +
Expand Down
4 changes: 3 additions & 1 deletion package.json
Expand Up @@ -17,7 +17,9 @@
},
"author": "Robert Jackson",
"license": "MIT",
"dependencies": {},
"dependencies": {
"clean-base-url": "^1.0.0"
},
"devDependencies": {},
"repository": {
"type": "git",
Expand Down

0 comments on commit 4b6c25a

Please sign in to comment.