Class: Dor::PidUtils

Inherits:
Object
  • Object
show all
Defined in:
lib/dor/utils/pid_utils.rb

Overview

Utilties for manipulating druids

Constant Summary collapse

PID_REGEX =
/[a-zA-Z]{2}[0-9]{3}[a-zA-Z]{2}[0-9]{4}/.freeze

Class Method Summary collapse

Class Method Details

.remove_druid_prefix(druid) ⇒ String

Since purl does not use the druid: prefix but much of dor does, use this function to strip the druid: if needed

Returns:

  • (String)

    the druid sans the druid: or if there was no druid: prefix, the entire string you passed



9
10
11
12
# File 'lib/dor/utils/pid_utils.rb', line 9

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