Skip to content

Commit 03e7e56

Browse files
abeisgoatlaurenzlong
authored andcommitted
Firestore path creation to path.join from concatenation
1 parent ecd07ae commit 03e7e56

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/providers/firestore.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23+
import { join } from 'path';
2324
import * as _ from 'lodash';
2425
import * as firebase from 'firebase-admin';
2526
import { apps } from '../apps';
@@ -34,7 +35,7 @@ export const defaultDatabase = '(default)';
3435
let firestoreInstance;
3536

3637
export function database(database: string = defaultDatabase) {
37-
return new DatabaseBuilder(`projects/${process.env.GCLOUD_PROJECT}/databases/${database}`);
38+
return new DatabaseBuilder(join('projects', process.env.GCLOUD_PROJECT, 'databases', database));
3839
}
3940

4041
export function namespace(namespace: string) {
@@ -50,11 +51,11 @@ export class DatabaseBuilder {
5051
constructor(private resource: string) { }
5152

5253
namespace(namespace: string) {
53-
return new NamespaceBuilder(`${this.resource}/documents@${namespace}`);
54+
return new NamespaceBuilder(`${join(this.resource, 'documents')}@${namespace}`);
5455
}
5556

5657
document(path: string) {
57-
return (new NamespaceBuilder(`${this.resource}/documents`)).document(path);
58+
return (new NamespaceBuilder(join(this.resource, 'documents'))).document(path);
5859
}
5960
}
6061

@@ -63,7 +64,7 @@ export class NamespaceBuilder {
6364
constructor(private resource: string) { }
6465

6566
document(path: string) {
66-
return new DocumentBuilder(`${this.resource}/${path}`);
67+
return new DocumentBuilder(join(this.resource, path));
6768
}
6869
}
6970

0 commit comments

Comments
 (0)