Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
211 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,7 @@ class Options { | |
this.handshake_timeout = 5000; | ||
|
||
var pluginOrder = []; | ||
|
||
Object.defineProperty(this, 'pluginOrder', { | ||
get () { return pluginOrder; }, | ||
set (v) { pluginOrder.push.apply(pluginOrder, v.split(/[,;]/)); } | ||
|
@@ -34,13 +35,17 @@ class Options { | |
|
||
Options.extract = function (document) { | ||
for (const element of Array.from(document.getElementsByTagName('script'))) { | ||
var m; var mm; | ||
var src = element.src; var srcAttr = element.getAttribute('src'); | ||
var src = element.src; | ||
var srcAttr = element.getAttribute('src'); | ||
var lrUrlRegexp = /^([^:]+:\/\/([^/:]+)(?::(\d+))?\/|\/\/|\/)?([^/].*\/)?z?livereload\.js(?:\?(.*))?$/; | ||
// ^proto:// ^host ^port ^// ^/ ^folder | ||
var lrUrlRegexpAttr = /^(?:(?:([^:/]+)?:?)\/{0,2})([^:]+)(?::(\d+))?/; | ||
// ^proto ^host/folder ^port | ||
if ((m = src.match(lrUrlRegexp)) && (mm = srcAttr.match(lrUrlRegexpAttr))) { | ||
|
||
var m = src.match(lrUrlRegexp); | ||
var mm = srcAttr.match(lrUrlRegexpAttr); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
smhg
Author
Contributor
|
||
|
||
if (m && mm) { | ||
const [, , host, port, , params] = m; | ||
const [, , , portFromAttr] = mm; | ||
const options = new Options(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
This introduced a bug for
<script>
tags without asrc
attribute.element.src
is an empty string, butelement.getAttribute('src')
isnull
. By rearranging this,mm = srcAttr.match(...)
is now run regardless of weatherm = ...
is truthy or not, and fails withTypeError: null is not an object (evaluating 'srcAttr.match')
.