Skip to content

Commit 60454fc

Browse files
committed
Fix loading code from URI
Previously, if you hit the "Copy URL" button and visit the URL in a different tab, you would not get the code that you had in the editor. For example, try https://try.ruby-lang.org/playground/#code=no&engine=cruby-3.2.0dev Additionally, if you edit the code in the URL and hit enter, you'd get a error in the JS console. Both of these issue were caused by getting a string back that start with a '#'. Delete this prefix.
1 parent b32cbad commit 60454fc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

source/javascripts/try_ruby.js.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def do_change_lang(event)
468468

469469
# Playground methods
470470
def get_state_from_url
471-
hash = $document.location.fragment.to_s
471+
hash = $document.location.fragment.to_s.delete_prefix('#')
472472
hash = Browser::FormData.parse_query(hash.gsub('+', ' '))
473473
[hash['code'], hash['engine']]
474474
end

0 commit comments

Comments
 (0)