Skip to content

Commit

Permalink
Fix: Search links rendered rich attributes break when value contains …
Browse files Browse the repository at this point in the history
…space
  • Loading branch information
psrok1 committed Jul 31, 2023
1 parent 0925e95 commit 1df7ae5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion mwdb/web/src/commons/helpers/renderTokens.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,10 @@ export function renderTokens(tokens: Token[], options?: Option): any {
if (token.href && token.href.startsWith("search#")) {
const query = token.href.slice("search#".length);
const search =
"?" + new URLSearchParams({ q: query }).toString();
"?" +
new URLSearchParams({
q: decodeURIComponent(query),
}).toString();
return (
<Link
key={uniqueId()}
Expand Down
3 changes: 2 additions & 1 deletion mwdb/web/src/components/RichAttribute/MarkedMustache.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class SearchReference {

toMarkdown() {
return `[${escapeMarkdown(this.value)}](search#${escapeMarkdown(
this.query
encodeURIComponent(this.query)
)})`;
}
}
Expand Down Expand Up @@ -218,5 +218,6 @@ export function renderValue(template: string, value: Object, options: Option) {
...marked.defaults,
tokenizer: markedTokenizer,
}) as Token[];
console.log(tokens);
return <div>{renderTokens(tokens, options)}</div>;
}

0 comments on commit 1df7ae5

Please sign in to comment.