From 317b02b9018bdfac94ee7a0a0e7c8f772147bc66 Mon Sep 17 00:00:00 2001 From: Salakar Date: Mon, 16 Apr 2018 16:21:24 +0100 Subject: [PATCH] [firestore] Path - remove unreachable code paths --- lib/modules/firestore/Path.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/modules/firestore/Path.js b/lib/modules/firestore/Path.js index dd215cb1..460c2763 100644 --- a/lib/modules/firestore/Path.js +++ b/lib/modules/firestore/Path.js @@ -14,11 +14,11 @@ export default class Path { } get id(): string | null { - return this._parts.length > 0 ? this._parts[this._parts.length - 1] : null; + return this._parts.length ? this._parts[this._parts.length - 1] : null; } get isDocument(): boolean { - return this._parts.length > 0 && this._parts.length % 2 === 0; + return this._parts.length % 2 === 0; } get isCollection(): boolean { @@ -34,7 +34,7 @@ export default class Path { } parent(): Path | null { - return this._parts.length > 0 + return this._parts.length ? new Path(this._parts.slice(0, this._parts.length - 1)) : null; } @@ -44,7 +44,8 @@ export default class Path { * @package */ static fromName(name: string): Path { + if (!name) return new Path([]); const parts = name.split('/'); - return parts.length === 0 ? new Path([]) : new Path(parts); + return new Path(parts); } }