pcottle / learnGitBranching

An interactive git visualization and tutorial. Aspiring students of git can use this app to educate and challenge themselves towards mastery of git!
https://pcottle.github.io/learnGitBranching/
MIT License
30.16k stars 5.72k forks source link

Add direct link to each level #1139

Closed pomeh closed 2 months ago

pomeh commented 2 months ago

Hello,

Thanks for this amazing work :)

I'm writing some articles on how to start with Git, and I'm willing to point readers to this awesome learning tool.

To keep it simple for readers, I would like to point them directly to one specific level, instead of the "home page" with all levels, but I can't find a permalink for that purpose.

I've tried to use the command query arg for that, it's working... almost. With a link like https://learngitbranching.js.org/?NODEMO=&command=level intro1 this works, but the problem is the space in the value level intro1 which may be replaced by level+intro1 in some browsers or situations, and then lead to an invalid command :cry:

To implement that, I was thinking of something like adding a new level query parameter, which value can be the same as the level command (intro1, rampup3, etc.): eg https://learngitbranching.js.org/?level=advanced2

Another possible fix I see would be to "unescape" the + sign when the command query arg is read, and the + being replaced by a single space. But this may have some unwanted side effects.

What do you think about this ?

pcottle commented 2 months ago

Ah yeah this is just a standard URL encoding issue. Most browsers will correctly substitute ` into%20` like so: https://learngitbranching.js.org/?NODEMO&command=level%20remote1

You can just provide this link instead so it doesn't break on other browsers! But I totally get that its a bit ugly of a url. I see you put up the PR to add support, so lets go with that :)