diff options
Diffstat (limited to 'skate/unstructured.go')
-rw-r--r-- | skate/unstructured.go | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/skate/unstructured.go b/skate/unstructured.go index 39821a1..a172e8b 100644 --- a/skate/unstructured.go +++ b/skate/unstructured.go @@ -2,19 +2,12 @@ package skate import ( "regexp" - "strings" ) var ( - PatDOI = regexp.MustCompile(`10[.][0-9]{1,8}/[^ ]*[\w]`) - PatDOINoHyphen = regexp.MustCompile(`10[.][0-9]{1,8}/[^ -]*[\w]`) - PatArxiv = regexp.MustCompile(`https?://arxiv.org/(pdf|abs)/([0-9]{4,4}[.][0-9]{1,8})(v[0-9]{1,2})?(.pdf)?`) - DOILinkPrefixes = []string{ - "http://doi.org/", - "http://dx.doi.org/", - "https://doi.org/", - "https://dx.doi.org/", - } + PatDOI = regexp.MustCompile(`10[.][0-9]{1,8}/[^ ]*[\w]`) + PatDOINoHyphen = regexp.MustCompile(`10[.][0-9]{1,8}/[^ -]*[\w]`) + PatArxiv = regexp.MustCompile(`https?://arxiv.org/(pdf|abs)/([0-9]{4,4}[.][0-9]{1,8})(v[0-9]{1,2})?(.pdf)?`) ) // ParseUnstructured will in-place augment missing DOI, arxiv id and so on. @@ -27,13 +20,7 @@ func ParseUnstructured(ref *Ref) error { // DOI v = PatDOI.FindString(uns) if v != "" && ref.Biblio.DOI == "" { - ref.Biblio.DOI = v - } - // DOI in URL - for _, prefix := range DOILinkPrefixes { - if ref.Biblio.DOI != "" && strings.HasPrefix(ref.Biblio.Url, prefix) { - ref.Biblio.DOI = strings.Replace(ref.Biblio.Url, prefix, "", -1) - } + ref.Biblio.DOI = SanitizeDOI(v) } // Arxiv vs = PatArxiv.FindStringSubmatch(uns) |