From 248b61bcd5604f45fc1feb9c9e4b29da36097e59 Mon Sep 17 00:00:00 2001 From: Mike Fix Date: Mon, 25 Mar 2019 09:38:14 -0700 Subject: [PATCH] correct pathname bug --- components/GistContainer.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/components/GistContainer.js b/components/GistContainer.js index d683247..4a24956 100644 --- a/components/GistContainer.js +++ b/components/GistContainer.js @@ -1,5 +1,6 @@ import React from 'react' import { withRouter } from 'next/router' +import url from 'url' import { escapeHtml } from '../lib/util' import ApiContext from './ApiContext' @@ -8,7 +9,8 @@ class GistContainer extends React.Component { static contextType = ApiContext async componentDidMount() { - const { pathname } = this.props.router + const { asPath = '' } = this.props.router + const { pathname } = url.parse(asPath, true) const path = escapeHtml(pathname.split('/').pop()) let newState = {}