Skip to content

Commit 16d3965

Browse files
committed
Add configs for GeoJSON files (.geojson)
Ensure that clients interpret the content of `.geojson` files correctly by serving them with the `application/vnd.geo+json` content-type. http://www.iana.org/assignments/media-types/application/vnd.geo+json Also, ensure that `.geojson` files aren't served with any of the `HTML` document related headers, but are served compressed, and their specified character encoding is UTF-8. Ref: http://geojson.org/geojson-spec.html
1 parent cf1ab4f commit 16d3965

File tree

5 files changed

+39
-12
lines changed

5 files changed

+39
-12
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### HEAD
2+
3+
* Add configs for GeoJSON files (`.geojson`).
4+
15
### 2.5.0 (June 14, 2014)
26

37
* Compress cache manifest files (`.appcache` / `.manifest`).

src/.htaccess

+10-7
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ Options -MultiViews
9797
Header set X-UA-Compatible "IE=edge"
9898
# `mod_headers` cannot match based on the content-type, however, this header
9999
# should be send only for HTML documents and not for the other resources
100-
<FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
100+
<FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
101101
Header unset X-UA-Compatible
102102
</FilesMatch>
103103
</IfModule>
@@ -136,6 +136,7 @@ Options -MultiViews
136136
# Data interchange
137137
AddType application/json json map
138138
AddType application/ld+json jsonld
139+
AddType application/vnd.geo+json geojson
139140

140141
# JavaScript
141142
# Normalize to standard type.
@@ -221,7 +222,7 @@ AddDefaultCharset utf-8
221222

222223
# Set `UTF-8` as the character encoding for other certain resources.
223224
<IfModule mod_mime.c>
224-
AddCharset utf-8 .atom .css .js .json .jsonld .rss .vtt .webapp .xml
225+
AddCharset utf-8 .atom .css .geojson .js .json .jsonld .rss .vtt .webapp .xml
225226
</IfModule>
226227

227228

@@ -233,8 +234,8 @@ AddDefaultCharset utf-8
233234
# | Rewrite engine |
234235
# ------------------------------------------------------------------------------
235236

236-
# Turn on the rewrite engine and enable the `FollowSymLinks` option (this is
237-
# necessary in order for the following directives to work).
237+
# Turn on the rewrite engine and enable the `FollowSymLinks` option
238+
# (this is necessary in order for the following directives to work).
238239

239240
# If your web host doesn't allow the `FollowSymlinks` option, you may need to
240241
# comment it out and use `Options +SymLinksIfOwnerMatch`, but be aware of the
@@ -330,7 +331,7 @@ AddDefaultCharset utf-8
330331

331332
# <IfModule mod_headers.c>
332333
# Header set X-Frame-Options "DENY"
333-
# <FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
334+
# <FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
334335
# Header unset X-Frame-Options
335336
# </FilesMatch>
336337
# </IfModule>
@@ -355,7 +356,7 @@ AddDefaultCharset utf-8
355356

356357
# <IfModule mod_headers.c>
357358
# Header set Content-Security-Policy "script-src 'self'; object-src 'self'"
358-
# <FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
359+
# <FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
359360
# Header unset Content-Security-Policy
360361
# </FilesMatch>
361362
# </IfModule>
@@ -485,7 +486,7 @@ AddDefaultCharset utf-8
485486
# <IfModule mod_headers.c>
486487
# # (1) (2)
487488
# Header set X-XSS-Protection "1; mode=block"
488-
# <FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
489+
# <FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
489490
# Header unset X-XSS-Protection
490491
# </FilesMatch>
491492
# </IfModule>
@@ -587,6 +588,7 @@ AddDefaultCharset utf-8
587588
application/ld+json \
588589
application/manifest+json \
589590
application/rss+xml \
591+
application/vnd.geo+json \
590592
application/vnd.ms-fontobject \
591593
application/x-font-ttf \
592594
application/x-web-app-manifest+json \
@@ -651,6 +653,7 @@ FileETag None
651653
# Data interchange
652654
ExpiresByType application/json "access plus 0 seconds"
653655
ExpiresByType application/ld+json "access plus 0 seconds"
656+
ExpiresByType application/vnd.geo+json "access plus 0 seconds"
654657
ExpiresByType application/xml "access plus 0 seconds"
655658
ExpiresByType text/xml "access plus 0 seconds"
656659

test/fixtures/content/.htaccess

+8-5
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ ErrorDocument 404 /404.html
6464
Header set X-UA-Compatible "IE=edge"
6565
# `mod_headers` cannot match based on the content-type, however, this header
6666
# should be send only for HTML documents and not for the other resources
67-
<FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
67+
<FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
6868
Header unset X-UA-Compatible
6969
</FilesMatch>
7070
</IfModule>
@@ -97,6 +97,7 @@ ErrorDocument 404 /404.html
9797
# Data interchange
9898
AddType application/json json map
9999
AddType application/ld+json jsonld
100+
AddType application/vnd.geo+json geojson
100101

101102
# JavaScript
102103
AddType application/javascript js
@@ -149,7 +150,7 @@ AddDefaultCharset utf-8
149150

150151
# Set `UTF-8` as the character encoding for other certain resources.
151152
<IfModule mod_mime.c>
152-
AddCharset utf-8 .atom .css .js .json .jsonld .rss .vtt .webapp .xml
153+
AddCharset utf-8 .atom .css .geojson .js .json .jsonld .rss .vtt .webapp .xml
153154
</IfModule>
154155

155156

@@ -206,7 +207,7 @@ AddDefaultCharset utf-8
206207

207208
<IfModule mod_headers.c>
208209
Header set X-Frame-Options "DENY"
209-
<FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
210+
<FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
210211
Header unset X-Frame-Options
211212
</FilesMatch>
212213
</IfModule>
@@ -217,7 +218,7 @@ AddDefaultCharset utf-8
217218

218219
<IfModule mod_headers.c>
219220
Header set Content-Security-Policy "script-src 'self'; object-src 'self'"
220-
<FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
221+
<FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
221222
Header unset Content-Security-Policy
222223
</FilesMatch>
223224
</IfModule>
@@ -278,7 +279,7 @@ AddDefaultCharset utf-8
278279

279280
<IfModule mod_headers.c>
280281
Header set X-XSS-Protection "1; mode=block"
281-
<FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
282+
<FilesMatch "\.(appcache|atom|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|tt[cf]|txt|vcf|vtt|webapp|web[mp]|woff|xml|xpi)$">
282283
Header unset X-XSS-Protection
283284
</FilesMatch>
284285
</IfModule>
@@ -321,6 +322,7 @@ AddDefaultCharset utf-8
321322
application/ld+json \
322323
application/manifest+json \
323324
application/rss+xml \
325+
application/vnd.geo+json \
324326
application/vnd.ms-fontobject \
325327
application/x-font-ttf \
326328
application/x-web-app-manifest+json \
@@ -379,6 +381,7 @@ FileETag None
379381
ExpiresByType application/json "access plus 0 seconds"
380382
ExpiresByType application/ld+json "access plus 0 seconds"
381383
ExpiresByType application/xml "access plus 0 seconds"
384+
ExpiresByType application/vnd.geo+json "access plus 0 seconds"
382385
ExpiresByType text/xml "access plus 0 seconds"
383386

384387
# Favicon (cannot be renamed!) and cursor images

test/fixtures/content/test.geojson

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"type": "Feature",
3+
"geometry": {
4+
"type": "Point",
5+
"coordinates": [ 23.590020, 46.769373 ]
6+
},
7+
"properties": {
8+
"name": "Unirii Square, Cluj-Napoca"
9+
}
10+
}

test/test.js

+7
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,13 @@ var tests = [
141141
})
142142
},
143143

144+
'test.geojson': {
145+
headers: generateHeaders({
146+
'cache-control': 'max-age=0, no-transform',
147+
'content-type': 'application/vnd.geo+json; charset=utf-8'
148+
})
149+
},
150+
144151
'test.gif': {
145152
headers: generateHeaders({
146153
'access-control-allow-origin': '*',

0 commit comments

Comments
 (0)