Sha256: 4c2b1a8794cdea37d5ec8e982f87e92699073d4f45d494b078d89e4fed02fbab
Contents?: true
Size: 982 Bytes
Versions: 4
Compression:
Stored size: 982 Bytes
Contents
module BookmarkUrl def my_host? url = ::Addressable::URI.parse(self) unless url.host raise ::Addressable::URI::InvalidURIError end config_url = ::Addressable::URI.parse(LibraryGroup.site_config.url) if url.host == config_url.host and url.port == config_url.port and ['http', 'https'].include?(url.scheme) true else false end end def bookmarkable? if self.my_host? url = ::Addressable::URI.parse(self) path = url.path.split("/").reverse if path[1] == "manifestations" and Manifestation.where(id: path[0]).first true else false end else true end rescue ::Addressable::URI::InvalidURIError false end def bookmarkable_id if self.my_host? path = ::Addressable::URI.parse(self).path.split("/").reverse unless path[1] == "manifestations" nil else path[0] end end end end class String include BookmarkUrl end
Version data entries
4 entries across 4 versions & 1 rubygems