Sha256: c1772b0fd39fad181c5f6d198f5f78ba7765dcaff24db425a48827a4d9580a19

Contents?: true

Size: 655 Bytes

Versions: 1

Compression:

Stored size: 655 Bytes

Contents

# frozen_string_literal: true

module Cocina
  module Models
    module Mapping
      # Utility methods for generating purl links
      class Purl
        class_attribute :base_url
        self.base_url = 'https://purl.stanford.edu'

        def self.for(druid:)
          return nil if druid.nil?

          "#{base_url}/#{druid.delete_prefix('druid:')}"
        end

        def self.purl?(node)
          node.start_with?("https://#{host}") || node.start_with?("http://#{host}")
        end

        # the purl without the protocol part
        def self.host
          @host ||= base_url.sub(%r{^https?://}, '')
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cocina-models-0.76.0 lib/cocina/models/mapping/purl.rb