@@ -95,6 +95,15 @@ describe('dynamicScript returns right script when', hooks => {
95
95
assert . strictEqual ( actual , 'http://localhost:35729/_lr/livereload.js?port=35729&host=localhost&path=_lr/livereload' ) ;
96
96
} ) ;
97
97
98
+ it ( 'liveReloadPort and port are same, but both are different from location.port' , assert => {
99
+ options . liveReloadPort = '9999' ;
100
+ options . port = '9999' ;
101
+ let script = InjectLiveReload . dynamicScript ( options ) ;
102
+ let actual = getScriptSrc ( script ) ;
103
+
104
+ assert . strictEqual ( actual , 'http://localhost:9999/_lr/livereload.js?port=9999&host=localhost&path=_lr/livereload' ) ;
105
+ } ) ;
106
+
98
107
it ( 'liveReloadPrefix is provided' , assert => {
99
108
options . liveReloadPrefix = 'other-lr-path' ;
100
109
let script = InjectLiveReload . dynamicScript ( options ) ;
@@ -161,12 +170,12 @@ describe('serverMiddleware', hooks => {
161
170
response . on ( 'end' , ( ) => {
162
171
assert . equal ( buf , `(function() {
163
172
var srcUrl = null;
164
- var host= location.hostname || 'localhost';
165
- var liveReloadPort = undefined ;
166
- var defaultPort = location.protocol === 'https:' ? 443 : 80;
167
- var port = liveReloadPort || location.port || defaultPort;
173
+ var host = location.hostname || 'localhost';
174
+ var useCustomPort = false || location.port !== 4200 ;
175
+ var defaultPort = location.port || (location. protocol === 'https:' ? 443 : 80) ;
176
+ var port = useCustomPort ? 4200 : defaultPort;
168
177
var path = '';
169
- var prefixURL = '';
178
+ var prefixURL = useCustomPort ? (location.protocol || 'http:') + '//' + host + ':' + 4200 : '';
170
179
var src = srcUrl || prefixURL + '/livereload.js?port=' + port + '&host=' + host + path;
171
180
var script = document.createElement('script');
172
181
script.type = 'text/javascript';
0 commit comments