FIX: support hashbang in url

diff --git a/lib/onebox/helpers.rb b/lib/onebox/helpers.rb
index 54007b1..54a9448 100644
--- a/lib/onebox/helpers.rb
+++ b/lib/onebox/helpers.rb
@@ -233,7 +233,10 @@ module Onebox
         encoded += '?' + query_string
       end
 
-      encoded += '#' + uri_query_encode(parts[:fragment]) unless parts[:fragment].nil?
+      unless parts[:fragment].nil?
+        encoded += '#' + uri_query_encode(parts[:fragment])&.gsub('%21%2F', '!/')
+      end
+
       encoded
     end
 
diff --git a/spec/lib/onebox/helpers_spec.rb b/spec/lib/onebox/helpers_spec.rb
index 04aae13..afa35eb 100644
--- a/spec/lib/onebox/helpers_spec.rb
+++ b/spec/lib/onebox/helpers_spec.rb
@@ -90,5 +90,8 @@ RSpec.describe Onebox::Helpers do
     it { expect(described_class.uri_encode("http://example.com/index.html?message=<script>alert('XSS');</script>")).to eq("http://example.com/index.html?message=%3Cscript%3Ealert%28%27XSS%27%29%3B%3C%2Fscript%3E") }
     it { expect(described_class.uri_encode("http://example.com/index.php/<IFRAME SRC=source.com onload='alert(document.cookie)'></IFRAME>")).to eq("http://example.com/index.php/%3CIFRAME%20SRC=source.com%20onload='alert(document.cookie)'%3E%3C/IFRAME%3E") }
     it { expect(described_class.uri_encode("https://en.wiktionary.org/wiki/greengrocer%27s_apostrophe")).to eq("https://en.wiktionary.org/wiki/greengrocer%27s_apostrophe") }
+
+    it { expect(described_class.uri_encode("https://example.com/random%2Bpath?q=random%2Bquery")).to eq("https://example.com/random%2Bpath?q=random%2Bquery") }
+    it { expect(described_class.uri_encode("https://glitch.com/edit/#!/equinox-watch")).to eq("https://glitch.com/edit/#!/equinox-watch") }
   end
 end

GitHub sha: 7bfbc3d7

This commit has been mentioned on Discourse Meta. There might be relevant details there:

This commit has been mentioned on Discourse Meta. There might be relevant details there: