From 9971ee8c9d7cf9e90b1b390141a7c16de2b96b25 Mon Sep 17 00:00:00 2001 From: ntma Date: Sat, 6 Jun 2020 19:40:59 +0100 Subject: [PATCH] Adds additional sanity test in exists(path) method --- src/index.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index cdf04c9..413762f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -275,7 +275,7 @@ export class Connection }) } - exists(path : string, callback : (error : Error, exists : boolean) => void) : void + exists(path : string, callback : (error : Error, exists ?: boolean) => void) : void { this.request({ url: path, @@ -284,7 +284,10 @@ export class Connection depth: '0' } }, (e, res, body) => { - callback(e, res.statusCode <= 400); + if(e) + return callback(e); + + callback(null, res.statusCode <= 400); }) }