77skipping=false
88curl () {
99 skipping=false
10- out=$( $( which curl) " $@ " 2>&1 ) ;
10+ out=$( $( which curl) " $@ " 2>&1 | sed ' s/\r$// ' ) ;
1111}
1212match () {
1313 [[ $skipping == true ]] && return 0
@@ -18,24 +18,28 @@ match() {
1818skipif () {
1919 echo " $out " | grep " $@ " > /dev/null && echo -n S && skipping=true || return 0
2020}
21+ skipifnot () {
22+ echo " $out " | grep " $@ " > /dev/null && return 0 || echo -n S && skipping=true
23+ }
2124
2225# check index endpoint
2326
2427curl -v $base / --compressed
2528match " HTTP/.* 200"
26- match -iP " Content-Type: text/html[\r\n]"
27- match -iP " Content-Encoding: br[\r\n]"
28- match -iP " Vary: Accept-Encoding[\r\n]"
29+ match -iE " Content-Type: text/html$"
30+ match -iE " Vary: Accept-Encoding$"
31+ skipifnot -iE " Accept-Encoding: (.*, ?)?br(,.*)?$"
32+ match -iE " Content-Encoding: br$"
2933
30- curl -v $base / --compressed -H ' Accept-Encoding: gzip, deflate '
34+ curl -v $base / --compressed -H ' Accept-Encoding: gzip'
3135match " HTTP/.* 200"
32- match -iP " Content-Type: text/html[\r\n] "
33- match -iP " Content-Encoding: gzip[\r\n] "
34- match -iP " Vary: Accept-Encoding[\r\n] "
36+ match -iE " Content-Type: text/html$ "
37+ match -iE " Content-Encoding: gzip$ "
38+ match -iE " Vary: Accept-Encoding$ "
3539
3640curl -v $base /robots.txt
3741match " HTTP/.* 200"
38- match -iP " Content-Type: text/plain[;\r\n] "
42+ match -iE " Content-Type: text/plain(;.*)?$ "
3943
4044curl -v $base /invalid
4145match " HTTP/.* 404"
@@ -45,85 +49,85 @@ match -i "Content-Type: text/html"
4549
4650curl -v $base /docs
4751match " HTTP/.* 301"
48- match -iP " Location: .*/docs/[\r\n] "
52+ match -iE " Location: .*/docs/$ "
4953
5054curl -v $base /docs/
5155match " HTTP/.* 302"
52- match -iP " Location: .*/docs/getting-started/[\r\n] "
56+ match -iE " Location: .*/docs/getting-started/$ "
5357
5458# check HTTP redirects behind CDN
5559
5660curl -v $base /docs -H ' X-Forwarded-Host: example.com' -H ' X-Forwarded-Proto: https'
5761match " HTTP/.* 301"
58- skipif -iP " Location: $base /docs/[\r\n] "
59- match -iP " Location: https://example\.com/docs/[\r\n] "
62+ skipif -iE " Location: $base /docs/$ "
63+ match -iE " Location: https://example\.com/docs/$ "
6064
6165curl -v $base /docs/ -H ' X-Forwarded-Host: example.com' -H ' X-Forwarded-Proto: http'
6266match " HTTP/.* 302"
63- skipif -iP " Location: $base /docs/getting-started/[\r\n] "
64- match -iP " Location: http://example\.com/docs/getting-started/[\r\n] "
67+ skipif -iE " Location: $base /docs/getting-started/$ "
68+ match -iE " Location: http://example\.com/docs/getting-started/$ "
6569
6670# check HTTP redirects for chapter endpoints
6771
6872curl -v $base /docs/getting-started/
6973match " HTTP/.* 302"
70- match -iP " Location: .*/docs/getting-started/quickstart/[\r\n] "
74+ match -iE " Location: .*/docs/getting-started/quickstart/$ "
7175
7276curl -v $base /docs/best-practices/
7377match " HTTP/.* 302"
74- match -iP " Location: .*/docs/best-practices/controllers/[\r\n] "
78+ match -iE " Location: .*/docs/best-practices/controllers/$ "
7579
7680curl -v $base /docs/api/
7781match " HTTP/.* 302"
78- match -iP " Location: .*/docs/api/app/[\r\n] "
82+ match -iE " Location: .*/docs/api/app/$ "
7983
8084curl -v $base /docs/async/
8185match " HTTP/.* 302"
82- match -iP " Location: .*/docs/async/fibers/[\r\n] "
86+ match -iE " Location: .*/docs/async/fibers/$ "
8387
8488curl -v $base /docs/integrations/
8589match " HTTP/.* 302"
86- match -iP " Location: .*/docs/integrations/database/[\r\n] "
90+ match -iE " Location: .*/docs/integrations/database/$ "
8791
8892# check HTTP redirects for `index.html` at end of path
8993
9094curl -v $base /index.html
9195match " HTTP/.* 301"
92- match -iP " Location: .*/[\r\n] "
96+ match -iE " Location: .*/$ "
9397
9498curl -v $base /docs/index.html
9599match " HTTP/.* 301"
96- match -iP " Location: .*/docs/[\r\n] "
100+ match -iE " Location: .*/docs/$ "
97101
98102curl -v $base /docs/getting-started/quickstart/index.html
99103match " HTTP/.* 301"
100- match -iP " Location: .*/docs/getting-started/quickstart/[\r\n] "
104+ match -iE " Location: .*/docs/getting-started/quickstart/$ "
101105
102106# check HTTP redirects for old documentation structure
103107
104108curl -v $base /docs/more/
105109match " HTTP/.* 302"
106- match -iP " Location: .*/\.\./getting-started/philosophy/[\r\n] "
110+ match -iE " Location: .*/\.\./getting-started/philosophy/$ "
107111
108112curl -v $base /docs/more/philosophy/
109113match " HTTP/.* 302"
110- match -iP " Location: .*/\.\./\.\./getting-started/philosophy/[\r\n] "
114+ match -iE " Location: .*/\.\./\.\./getting-started/philosophy/$ "
111115
112116curl -v $base /docs/more/architecture/
113117match " HTTP/.* 302"
114- match -iP " Location: .*/\.\./\.\./getting-started/philosophy/[\r\n] "
118+ match -iE " Location: .*/\.\./\.\./getting-started/philosophy/$ "
115119
116120curl -v $base /docs/more/community/
117121match " HTTP/.* 302"
118- match -iP " Location: .*/\.\./\.\./getting-started/community/[\r\n] "
122+ match -iE " Location: .*/\.\./\.\./getting-started/community/$ "
119123
120124curl -v $base /docs/async/child-processes/
121125match " HTTP/.* 302"
122- match -iP " Location: .*/\.\./\.\./integrations/child-processes/[\r\n] "
126+ match -iE " Location: .*/\.\./\.\./integrations/child-processes/$ "
123127
124128curl -v $base /docs/async/streaming/
125129match " HTTP/.* 302"
126- match -iP " Location: .*/\.\./\.\./integrations/streaming/[\r\n] "
130+ match -iE " Location: .*/\.\./\.\./integrations/streaming/$ "
127131
128132# end
129133
0 commit comments