Skip to content

Commit 2547c59

Browse files
committed
fix problem with getting URL data (fix #162)
1 parent 00a072c commit 2547c59

8 files changed

Lines changed: 19 additions & 9 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
## Unreleased
44

5+
## [v1.1.11] - 2026-05-19 Tue
6+
7+
- Fix [#162]: Fix URL ingestion. It stopped working because sites like
8+
Wikipedia became less permissive to empty user agents and requests that
9+
do not specify text/http in the header.
10+
- Fix: prevent crashes caused by "perfect" odds edge case.
11+
512
## [v1.1.10] - 2025-04-17 Thu
613

714
- Add: slog as as a logging engine.

CITATION.cff

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
cff-version: 1.2.0
22
message: "If you use this software, please cite it as below."
33
title: "GNfinder -- a finder of scientific names in a variety of media."
4-
version: v1.1.5
4+
version: v1.1.11
55
authors:
66
- family-names: "Mozzherin"
77
given-names: "Dmitry"
88
orcid: "https://orcid.org/0000-0003-1593-1417"
99
repository-code: "https://github.com/gnames/gnfinder"
10-
date-released: 2024-05-24
10+
date-released: 2026-05-19
1111
doi: 10.5281/zenodo.10070488
1212
license: MIT

cmd/root.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,8 @@ verification results.
160160
input = "STDIN"
161161
case 1:
162162
input = args[0]
163-
d := gndoc.New(cfg.TikaURL)
163+
ua := "gnfinder/" + gnfinder.Version + " (https://github.com/gnames/gnfinder)"
164+
d := gndoc.New(cfg.TikaURL, gndoc.OptUserAgent(ua))
164165
if strings.HasPrefix(input, "http") {
165166
data, convDur, err = d.TextFromURL(input)
166167
} else {

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/abadojack/whatlanggo v1.0.1
77
github.com/aclements/perflock v0.0.0-20240209181333-b67f3f23152f
88
github.com/gnames/bayes v0.5.3
9-
github.com/gnames/gndoc v0.3.2
9+
github.com/gnames/gndoc v0.3.3
1010
github.com/gnames/gner v0.1.6
1111
github.com/gnames/gnfmt v0.6.0
1212
github.com/gnames/gnlib v0.47.0

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,8 @@ github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8
129129
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
130130
github.com/gnames/bayes v0.5.3 h1:CFr1tYqmvo+VNFKLXQ/Dl58KFFpcnJbFK5csY+w1nI0=
131131
github.com/gnames/bayes v0.5.3/go.mod h1:tiWMnXQ30NZAyxfwysZsnFPTTehpEwiL3cQThuYF8sc=
132-
github.com/gnames/gndoc v0.3.2 h1:A7GpdFh6fvjpdisDGwk85p1ihDkpZ59WtPDUfnmT7eU=
133-
github.com/gnames/gndoc v0.3.2/go.mod h1:SWHl1vRaVlc0E1oftUseKVq6S1GjY8jYYv5tgUBpdy8=
132+
github.com/gnames/gndoc v0.3.3 h1:TNmHelaWD5RN9Ryra4BMO55/R+ZTmv9O1Bmo1vcQJzg=
133+
github.com/gnames/gndoc v0.3.3/go.mod h1:SWHl1vRaVlc0E1oftUseKVq6S1GjY8jYYv5tgUBpdy8=
134134
github.com/gnames/gner v0.1.6 h1:KzAAw2Lxr5GLoh5/ouMEPIuqFzt3TGVgJ0/ny0YgohE=
135135
github.com/gnames/gner v0.1.6/go.mod h1:GXQJ07xu31O9ufuUBhVE1JKrhc0YUBneNm3CBr82koc=
136136
github.com/gnames/gnfmt v0.6.0 h1:u+OjRyD8cVywB00IGKf24xTovz9y807E1fAa22+HInc=

pkg/io/web/api.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,9 @@ func getText(
228228
return params.Text, filename, dur, err
229229
}
230230

231-
d := gndoc.New(tikaURL)
232231
if params.URL != "" {
232+
ua := "gnfinder/" + gnfinder.Version + " (https://github.com/gnames/gnfinder)"
233+
d := gndoc.New(tikaURL, gndoc.OptUserAgent(ua))
233234
txt, dur, err = d.TextFromURL(params.URL)
234235
return txt, filename, dur, err
235236
}

pkg/io/web/web.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ func find(gnf gnfinder.GNfinder) func(echo.Context) error {
7070
if t := params.Text; t != "" {
7171
txt = t
7272
} else if url := params.URL; url != "" {
73-
doc := gndoc.New(tikaURL)
73+
ua := "gnfinder/" + gnfinder.Version + " (https://github.com/gnames/gnfinder)"
74+
doc := gndoc.New(tikaURL, gndoc.OptUserAgent(ua))
7475
txt, dur.TextExtraction, err = doc.TextFromURL(url)
7576
} else {
7677
txt, filename, dur.TextExtraction, err = textFromFile(c, tikaURL)

pkg/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package gnfinder
22

33
var (
4-
Version = "v1.1.10"
4+
Version = "v1.1.11"
55
Build string
66
)

0 commit comments

Comments
 (0)