aboutsummaryrefslogtreecommitdiffstats
path: root/rust/src/identifiers.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2020-12-02 10:47:52 -0800
committerBryan Newbold <bnewbold@robocracy.org>2020-12-17 23:03:08 -0800
commit5a139a680a40a9628cd4c0116226f7c9ae470572 (patch)
tree54942a66f2d962ac2a7b270c781e3878194dd8cf /rust/src/identifiers.rs
parent53b17b96c61ecfe14a30da523e993a9902d7f375 (diff)
downloadfatcat-5a139a680a40a9628cd4c0116226f7c9ae470572.tar.gz
fatcat-5a139a680a40a9628cd4c0116226f7c9ae470572.zip
rust: rename and improve dblp key (id) syntax check
Diffstat (limited to 'rust/src/identifiers.rs')
-rw-r--r--rust/src/identifiers.rs24
1 files changed, 16 insertions, 8 deletions
diff --git a/rust/src/identifiers.rs b/rust/src/identifiers.rs
index 76f978f9..9d766417 100644
--- a/rust/src/identifiers.rs
+++ b/rust/src/identifiers.rs
@@ -388,15 +388,15 @@ fn test_check_doaj_id() {
assert!(check_doaj_id("1b39813549077b2347c0f370c3864b411").is_err());
}
-pub fn check_dblp_id(raw: &str) -> Result<()> {
+pub fn check_dblp_key(raw: &str) -> Result<()> {
lazy_static! {
// TODO: what should this actually be? more or less restrictive?
- static ref RE: Regex = Regex::new(r"^[a-z]+/[a-zA-Z0-9]+/[a-zA-Z0-9/]+$").unwrap();
+ static ref RE: Regex = Regex::new(r"^(journals|conf|series|phd|books|tr|ms|www)(/[a-zA-Z0-9-+]+){1,4}$").unwrap();
}
if raw.is_ascii() && RE.is_match(raw) {
Ok(())
} else {
- Err(FatcatError::MalformedChecksum(
+ Err(FatcatError::MalformedExternalId(
"dblp Article Key (expected, eg, 'journals/entcs/GoubaultM12')".to_string(),
raw.to_string(),
))?
@@ -404,11 +404,19 @@ pub fn check_dblp_id(raw: &str) -> Result<()> {
}
#[test]
-fn test_check_dblp_id() {
- assert!(check_dblp_id("journals/entcs/GoubaultM12").is_ok());
- assert!(check_dblp_id("journals/entcs/GoubaultM12").is_ok());
- assert!(check_dblp_id("10.123*").is_err());
- assert!(check_dblp_id("").is_err());
+fn test_check_dblp_key() {
+ assert!(check_dblp_key("journals/entcs/GoubaultM12").is_ok());
+ assert!(check_dblp_key("journals/entcs/GoubaultM12").is_ok());
+ assert!(check_dblp_key("conf/entcs/GoubaultM12").is_ok());
+ assert!(check_dblp_key("conf/3dica/DorringtonGCPS11").is_ok());
+ assert!(check_dblp_key("conf/c++/CohenHS91").is_ok());
+ assert!(check_dblp_key("phd/Hoff2002").is_ok());
+ assert!(check_dblp_key("phd/dk/Heine2010").is_ok());
+ assert!(check_dblp_key("phd/Beferull-Lozano02").is_ok());
+ assert!(check_dblp_key("www/org/w3/TR/xmlquery-use-cases").is_ok());
+ assert!(check_dblp_key("books/mc/18/KuznetsovSPCSS18").is_ok());
+ assert!(check_dblp_key("10.123*").is_err());
+ assert!(check_dblp_key("").is_err());
}
pub fn check_oai_id(raw: &str) -> Result<()> {