bug(deeplinking): escaping breaks whitespaces & underscored tags/ids (via #4953)

* add tests for operation lacking an operationId
* add deep linking tests for tags/operationIds with underscores
* migrate from `_` to `%20` for deeplink hash whitespace escaping
* add backwards compatibility for `_` whitespace escaping
* update util unit tests
This commit is contained in:
kyle
2018-10-16 18:51:29 -05:00
committed by GitHub
parent 94b1355700
commit 3c3b7e0bf1
7 changed files with 231 additions and 12 deletions

View File

@@ -733,8 +733,10 @@ export function getAcceptControllingResponse(responses) {
return suitable2xxResponse || suitableDefaultResponse
}
export const createDeepLinkPath = (str) => typeof str == "string" || str instanceof String ? str.trim().replace(/\s/g, "_") : ""
export const escapeDeepLinkPath = (str) => cssEscape( createDeepLinkPath(str) )
// suitable for use in URL fragments
export const createDeepLinkPath = (str) => typeof str == "string" || str instanceof String ? str.trim().replace(/\s/g, "%20") : ""
// suitable for use in CSS classes and ids
export const escapeDeepLinkPath = (str) => cssEscape( createDeepLinkPath(str).replace(/%20/g, "_") )
export const getExtensions = (defObj) => defObj.filter((v, k) => /^x-/.test(k))
export const getCommonExtensions = (defObj) => defObj.filter((v, k) => /^pattern|maxLength|minLength|maximum|minimum/.test(k))