DEV: assign constant to `preserve_fragment_url_hosts`

DEV: assign constant to `preserve_fragment_url_hosts`
diff --git a/lib/oneboxer.rb b/lib/oneboxer.rb
index 69011d0..72d697c 100644
--- a/lib/oneboxer.rb
+++ b/lib/oneboxer.rb
@@ -260,7 +260,7 @@ module Oneboxer
   def self.preserve_fragment_url_hosts
-    ['']
+    @preserve_fragment_url_hosts ||= ['']
   def self.external_onebox(url)

sha: e5fd018f

I wonder if we should only store the hostname instead of the URL? ( vs


URL is required here because we are parsing URI when matching hostname as per:

This results in:

[1] pry(main)> uri = URI.parse('')
=> #<URI::Generic>
[2] pry(main)> uri.hostname
=> nil
[3] pry(main)> uri = URI.parse('')
=> #<URI::HTTP>
[4] pry(main)> uri.hostname
=> ""

I tried amending uri method to add schema when only domain is being passed but that resulted in failure of multiple specs, including:

So it is required by design to pass URL instead of domain. I took the initial cue (to add URL) from:

1 Like