summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.name>2020-09-08 15:48:13 +0100
committerNick White <git@njw.name>2020-09-08 15:48:13 +0100
commite292f759acc8b46523c7ac0cdf44b301b6d9eb73 (patch)
treeb65392084c51bd47f4c2df5100ccdba9d6fb5600
parent900dbc1c02c9c3b11fe265479dbdf07a75a91318 (diff)
Sanitise URLs so that // in url doesn't cause issues (bsb site can spew these)
-rw-r--r--cmd/iiifdownloader/main.go15
1 files changed, 12 insertions, 3 deletions
diff --git a/cmd/iiifdownloader/main.go b/cmd/iiifdownloader/main.go
index 57247cc..55b72b2 100644
--- a/cmd/iiifdownloader/main.go
+++ b/cmd/iiifdownloader/main.go
@@ -21,8 +21,9 @@ const usage = `Usage: iiifdownloader url
Downloads all pages from a IIIF server.
Currently supports the following IIIF using services:
-- BNF's Gallica (any book or page URL should work)
-- BSB / MDZ / DFG
+- BNF's Gallica
+- BSB / MDZ
+- DFG Viewer
`
const bnfPrefix = `https://gallica.bnf.fr/ark:/`
@@ -294,6 +295,14 @@ func dlNoPgNums(bookdir, pgurlStart, pgurlEnd, pgurlAltStart, pgurlAltEnd string
}
}
+func sanitiseUrl(u string) string {
+ var s string
+ s = strings.Replace(u, "//", "/", -1)
+ s = strings.Replace(s, "https:/", "https://", -1)
+ s = strings.Replace(s, "http:/", "http://", -1)
+ return s
+}
+
func main() {
flag.Usage = func() {
fmt.Fprintf(flag.CommandLine.Output(), usage)
@@ -306,7 +315,7 @@ func main() {
return
}
- u := flag.Arg(0)
+ u := sanitiseUrl(flag.Arg(0))
var bookdir string
var pgurlStart, pgurlEnd string