about summary refs log tree commit diff
path: root/app/helpers/jsonld_helper.rb
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-03-12 20:54:13 +0100
committerGitHub <noreply@github.com>2022-03-12 20:54:13 +0100
commit988f5bf0266483659b03f1b0926d0b9ff9e85a8f (patch)
tree1e0a0011a890729f45c0d364641c266864e78d02 /app/helpers/jsonld_helper.rb
parent2c8bb1745359a3bf200d37383dc56d5951e2b6bc (diff)
parent8d4b5ee3ef5e8df3a92e19f2c3f3a4560341eef3 (diff)
Merge pull request #1716 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
Diffstat (limited to 'app/helpers/jsonld_helper.rb')
-rw-r--r--app/helpers/jsonld_helper.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/app/helpers/jsonld_helper.rb b/app/helpers/jsonld_helper.rb
index c6557817d..102e4b132 100644
--- a/app/helpers/jsonld_helper.rb
+++ b/app/helpers/jsonld_helper.rb
@@ -15,6 +15,14 @@ module JsonLdHelper
     value.is_a?(Array) ? value.first : value
   end
 
+  def uri_from_bearcap(str)
+    if str&.start_with?('bear:')
+      Addressable::URI.parse(str).query_values['u']
+    else
+      str
+    end
+  end
+
   # The url attribute can be a string, an array of strings, or an array of objects.
   # The objects could include a mimeType. Not-included mimeType means it's text/html.
   def url_to_href(value, preferred_type = nil)
@@ -54,7 +62,7 @@ module JsonLdHelper
   end
 
   def unsupported_uri_scheme?(uri)
-    !uri.start_with?('http://', 'https://')
+    uri.nil? || !uri.start_with?('http://', 'https://')
   end
 
   def invalid_origin?(url)