From 4a9c3b676369533f2ec63e4181de205f265101c3 Mon Sep 17 00:00:00 2001 From: Chris Bojemski Date: Mon, 24 Feb 2020 11:50:12 -0800 Subject: [PATCH] Fix split --- src/components/Redoc/Redoc.tsx | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/components/Redoc/Redoc.tsx b/src/components/Redoc/Redoc.tsx index b32bc958..be499400 100644 --- a/src/components/Redoc/Redoc.tsx +++ b/src/components/Redoc/Redoc.tsx @@ -35,7 +35,12 @@ export class Redoc extends React.Component { state = { activeSelection: undefined }; - HOMEPAGE_URL = "https://admin.instagram.com/admin/api/docs"; + /* + PROBLEM! This will never be true during testing. + Let's at least test to see if current URL endsWith + /admin/api/docs/ (trailing slash required). + */ + HOMEPAGE_ENDING = "/admin/api/docs/" getTagByName(tagName: string): IMenuItem | undefined { const menu = this.props.store.menu; @@ -58,14 +63,14 @@ export class Redoc extends React.Component { } shouldInitializeWithActiveSelection(): Boolean { - if (this.state.activeSelection === undefined && window.location.href === this.HOMEPAGE_URL) { + if (this.state.activeSelection === undefined && window.location.href.endsWith(this.HOMEPAGE_ENDING)) { return false; }; return true; } sitePathIsTag(sitePath: string): Boolean { - return sitePath.startsWith('/#tag') && !this.sitePathIsOperation(sitePath); + return sitePath.startsWith('#tag') && !this.sitePathIsOperation(sitePath); } sitePathIsOperation(sitePath: string): Boolean { @@ -73,7 +78,7 @@ export class Redoc extends React.Component { } parseSitePath(fullUrl: string): string { - return fullUrl.split(this.HOMEPAGE_URL)[1]; + return fullUrl.split(this.HOMEPAGE_ENDING)[1]; } nonHomepageLocationIsTag(sitePath: string) {