Skip to content

Commit ca72e94

Browse files
committed
Fixed callback error in the start method
1 parent 880dd8a commit ca72e94

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

lib/server/WebDAVServer.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,13 @@ var WebDAVServer = (function () {
168168
if (callback)
169169
throw new Error('Illegal arguments');
170170
}
171+
if (_callback) {
172+
var _callback_1 = _callback;
173+
_callback = function () {
174+
if (_callback_1)
175+
_callback_1(_this.server);
176+
};
177+
}
171178
if (!this.server) {
172179
this.server = http.createServer(function (req, res) {
173180
var method = _this.methods[_this.normalizeMethodName(req.method)];
@@ -211,10 +218,7 @@ var WebDAVServer = (function () {
211218
});
212219
});
213220
}
214-
this.server.listen(_port, this.options.hostname, function () {
215-
if (_callback)
216-
_callback(_this.server);
217-
});
221+
this.server.listen(_port, this.options.hostname, _callback);
218222
};
219223
WebDAVServer.prototype.stop = function (callback) {
220224
if (this.server) {

src/server/WebDAVServer.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,14 @@ export class WebDAVServer
253253
if(callback)
254254
throw new Error('Illegal arguments');
255255
}
256+
if(_callback)
257+
{
258+
const _callback_ = _callback;
259+
_callback = () => {
260+
if(_callback_)
261+
_callback_(this.server);
262+
}
263+
}
256264

257265
if(!this.server)
258266
{
@@ -310,10 +318,7 @@ export class WebDAVServer
310318
})
311319
}
312320

313-
this.server.listen(_port, this.options.hostname, () => {
314-
if(_callback)
315-
_callback(this.server);
316-
});
321+
this.server.listen(_port, this.options.hostname, _callback);
317322
}
318323

319324
stop(callback : () => void)

0 commit comments

Comments
 (0)