Skip to content

Fix "try in playground" URLs broken when b64 contains + #24

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: generator
Choose a base branch
from

Conversation

hchargois
Copy link

The "Try it in the playground" links in code blocks are broken when the base64 encoding of the code contains the character +, as it is a reserved character in URLs which gets replaced by a space on the playground's end, which completely breaks the code.

Example: the first code block of this section https://docs.vlang.io/functions-2.html#lambda-expressions

Should be

mut a := [1, 2, 3]
a.sort(|x, y| x > y) // sorts the array, defining the comparator with a lambda expression
println(a.map(|x| x * 10)) // prints [30, 20, 10]

But in the playground it opens like so:

image

Some blocks are even more broken, such as this one https://docs.vlang.io/concurrency.html#channel-select which makes the playground fail to display anything.

The fix is simple, correctly encode the query param value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant