From dd50922747f9949d852d466456af894c9036b03e Mon Sep 17 00:00:00 2001 From: Peter Bacon Darwin Date: Sat, 4 Mar 2017 16:24:09 +0000 Subject: [PATCH] refactor(aio): move document path computation Do the path computation before doing the cache look up. --- aio/src/app/documents/document.service.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/aio/src/app/documents/document.service.ts b/aio/src/app/documents/document.service.ts index fb15f22cb9..a4d12dd9c4 100644 --- a/aio/src/app/documents/document.service.ts +++ b/aio/src/app/documents/document.service.ts @@ -29,14 +29,14 @@ export class DocumentService { private getDocument(url: string) { this.logger.log('getting document', url); - if ( !this.cache.has(url)) { - this.cache.set(url, this.fetchDocument(url)); + const path = this.computePath(url); + if ( !this.cache.has(path)) { + this.cache.set(path, this.fetchDocument(path)); } - return this.cache.get(url); + return this.cache.get(path); } - private fetchDocument(url: string) { - const path = this.computePath(url); + private fetchDocument(path: string) { this.logger.log('fetching document from', path); const subject = new AsyncSubject(); this.http