diff --git a/.changeset/poor-news-joke.md b/.changeset/poor-news-joke.md new file mode 100644 index 00000000..6d3af8d6 --- /dev/null +++ b/.changeset/poor-news-joke.md @@ -0,0 +1,5 @@ +--- +"counterfact": patch +--- + +work-around for URL-encoding in path names (#1083) diff --git a/src/typescript-generator/requirement.js b/src/typescript-generator/requirement.js index 07f78da0..4791e306 100644 --- a/src/typescript-generator/requirement.js +++ b/src/typescript-generator/requirement.js @@ -38,7 +38,13 @@ export class Requirement { } select(path, data = this.data, basePath = "") { - const parts = path.split("/").map(this.unescapeJsonPointer); + const parts = path + .split("/") + .map(this.unescapeJsonPointer) + // Unescape URL encoded characters (e.g. %20 -> " ") + // Technically we should not be unescaping, but it came up in https://github.com/pmcelhaney/counterfact/issues/1083 + // and I can't think of a reason anyone would intentionally put a % in a key name. + .map(unescape); let result = this;