File tree 1 file changed +9
-10
lines changed 1 file changed +9
-10
lines changed Original file line number Diff line number Diff line change @@ -3,18 +3,17 @@ var SockJS = require("sockjs-client");
3
3
var stripAnsi = require ( 'strip-ansi' ) ;
4
4
5
5
function getCurrentScriptSource ( ) {
6
- // try to get the current script
7
- if ( document . currentScript ) {
6
+ // `document.currentScript` is the most accurate way to find the current script,
7
+ // but is not supported in all browsers.
8
+ if ( document . currentScript )
8
9
return document . currentScript . getAttribute ( "src" ) ;
9
- }
10
- // fall back to getting all scripts in the document
11
- var scriptElements = document . scripts || [ ] ,
12
- currentScript = scriptElements [ scriptElements . length - 1 ] ;
13
- if ( currentScript ) {
10
+ // Fall back to getting all scripts in the document.
11
+ var scriptElements = document . scripts || [ ] ;
12
+ var currentScript = scriptElements [ scriptElements . length - 1 ] ;
13
+ if ( currentScript )
14
14
return currentScript . getAttribute ( "src" ) ;
15
- }
16
- // fail as there was no script to use
17
- throw new Error ( "Failed to get current script source" ) ;
15
+ // Fail as there was no script to use.
16
+ throw new Error ( "[WDS] Failed to get current script source" ) ;
18
17
}
19
18
20
19
var urlParts ;
You can’t perform that action at this time.
0 commit comments