Replace spaces with underscores when setting the hash value and inserting the ID into the DOM. Escape the deep link path when querying for the DOM element on hash change.

This commit is contained in:
Owen Conti
2017-09-13 21:32:46 -06:00
parent 16364fb81e
commit a6e070ac76
5 changed files with 14 additions and 10 deletions

View File

@@ -8,6 +8,7 @@ import some from "lodash/some"
import eq from "lodash/eq"
import { memoizedSampleFromSchema, memoizedCreateXMLExample } from "core/plugins/samples/fn"
import win from "./window"
import cssEscape from "css.escape"
const DEFAULT_REPONSE_KEY = "default"
@@ -651,4 +652,5 @@ export const shallowEqualKeys = (a,b, keys) => {
})
}
export const replaceSpacesWithUnderscores = (str) => str.replace(/\s/, "_")
export const createDeepLinkPath = (str) => str.replace(/\s/g, "_")
export const escapeDeepLinkPath = (str) => cssEscape( createDeepLinkPath(str) )