Sha256: 136c46acf5af95dc90c78516f25ec1f4ad7f63b53f59cfc8850e117ebac5f379

Contents?: true

Size: 597 Bytes

Versions: 24

Compression:

Stored size: 597 Bytes

Contents

# frozen_string_literal: true

module Dor
  # Utilties for manipulating druids
  class PidUtils
    PID_REGEX = /[a-zA-Z]{2}[0-9]{3}[a-zA-Z]{2}[0-9]{4}/.freeze
    # Since purl does not use the druid: prefix but much of dor does, use this function to strip the druid: if needed
    # @return [String] the druid sans the druid: or if there was no druid: prefix, the entire string you passed
    def self.remove_druid_prefix(druid)
      result = druid.match(PID_REGEX)
      result.nil? ? druid : result[0] # if no matches, return the string passed in, otherwise return the match
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
dor-services-9.6.2 lib/dor/utils/pid_utils.rb
dor-services-9.6.1 lib/dor/utils/pid_utils.rb
dor-services-9.6.0 lib/dor/utils/pid_utils.rb
dor-services-9.5.0 lib/dor/utils/pid_utils.rb
dor-services-9.4.0 lib/dor/utils/pid_utils.rb
dor-services-9.3.0 lib/dor/utils/pid_utils.rb
dor-services-9.2.1 lib/dor/utils/pid_utils.rb
dor-services-9.2.0 lib/dor/utils/pid_utils.rb
dor-services-9.1.0 lib/dor/utils/pid_utils.rb
dor-services-9.0.0 lib/dor/utils/pid_utils.rb
dor-services-8.6.0 lib/dor/utils/pid_utils.rb
dor-services-8.5.0 lib/dor/utils/pid_utils.rb
dor-services-8.4.0 lib/dor/utils/pid_utils.rb
dor-services-8.3.0 lib/dor/utils/pid_utils.rb
dor-services-8.2.0 lib/dor/utils/pid_utils.rb
dor-services-8.1.1 lib/dor/utils/pid_utils.rb
dor-services-8.1.0 lib/dor/utils/pid_utils.rb
dor-services-8.0.0 lib/dor/utils/pid_utils.rb
dor-services-7.2.4 lib/dor/utils/pid_utils.rb
dor-services-7.2.3 lib/dor/utils/pid_utils.rb