tangled
alpha
login
or
join now
whitequark.org
/
git-pages-cli
1
fork
atom
[mirror] Command-line application for uploading a site to a git-pages server
1
fork
atom
overview
issues
pulls
pipelines
Bail out if the Server header does not indicate git-pages.
miyuko
1 week ago
c05d1fd2
7674f98b
+11
1 changed file
expand all
collapse all
unified
split
main.go
+11
main.go
···
14
14
"net/http"
15
15
"net/url"
16
16
"os"
17
17
+
"regexp"
17
18
"runtime/debug"
18
19
"strconv"
19
20
"strings"
···
372
373
response, err := http.DefaultClient.Do(request)
373
374
if err != nil {
374
375
fmt.Fprintf(os.Stderr, "error: %s\n", err)
376
376
+
os.Exit(1)
377
377
+
}
378
378
+
serverIdent := strings.Join(response.Header.Values("Server"), ", ")
379
379
+
//lint:ignore SA6000 This isn't a hot loop.
380
380
+
if matched, err := regexp.MatchString(`\bgit-pages\b`, serverIdent); err != nil {
381
381
+
panic(err)
382
382
+
} else if !matched {
383
383
+
fmt.Fprintf(os.Stderr,
384
384
+
"error: the tool only works with git-pages, but the URL points to a %q server\n",
385
385
+
serverIdent)
375
386
os.Exit(1)
376
387
}
377
388
if displayServer {