Skip to content

Commit

Permalink
Serve .md and .markdown files as text/markdown.
Browse files Browse the repository at this point in the history
Per RFC 7763 - https://tools.ietf.org/html/rfc7763

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

Thanks @mathiasbynens!

Closes #94
  • Loading branch information
hatzopoulos authored and XhmikosR committed Sep 4, 2017
1 parent 9965d0f commit bfcafd3
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/internet_explorer/x-ua-compatible.conf
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
# the `X-UA-Compatible` response header should be send only for
# HTML documents and not for the other resources.

<FilesMatch "\.(appcache|atom|bbaw|bmp|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|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|markdown|md|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
Header unset X-UA-Compatible
</FilesMatch>

Expand Down
2 changes: 2 additions & 0 deletions src/media_types/character_encodings.conf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ AddDefaultCharset utf-8
.json \
.jsonld \
.manifest \
.markdown \
.md \
.rdf \
.rss \
.topojson \
Expand Down
1 change: 1 addition & 0 deletions src/media_types/media_types.conf
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
AddType application/x-chrome-extension crx
AddType application/x-opera-extension oex
AddType application/x-xpinstall xpi
AddType text/markdown markdown md
AddType text/vcard vcard vcf
AddType text/vnd.rim.location.xloc xloc
AddType text/vtt vtt
Expand Down
2 changes: 1 addition & 1 deletion src/security/content-security-policy.conf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
# the `Content-Security-Policy` response header should be send
# only for HTML documents and not for the other resources.

<FilesMatch "\.(appcache|atom|bbaw|bmp|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|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|markdown|md|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
Header unset Content-Security-Policy
</FilesMatch>

Expand Down
2 changes: 1 addition & 1 deletion src/security/x-frame-option.conf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
# the `X-Frame-Options` response header should be send only for
# HTML documents and not for the other resources.

<FilesMatch "\.(appcache|atom|bbaw|bmp|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|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|markdown|md|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
Header unset X-Frame-Options
</FilesMatch>

Expand Down
2 changes: 1 addition & 1 deletion src/security/x-xss-protection.conf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# the `X-XSS-Protection` response header should be send only for
# HTML documents and not for the other resources.

<FilesMatch "\.(appcache|atom|bbaw|bmp|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|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
<FilesMatch "\.(appcache|atom|bbaw|bmp|crx|css|cur|eot|f4[abpv]|flv|geojson|gif|htc|ico|jpe?g|js|json(ld)?|m4[av]|manifest|map|markdown|md|mp4|oex|og[agv]|opus|otf|pdf|png|rdf|rss|safariextz|svgz?|swf|topojson|tt[cf]|txt|vcard|vcf|vtt|webapp|web[mp]|webmanifest|woff2?|xloc|xml|xpi)$">
Header unset X-XSS-Protection
</FilesMatch>

Expand Down
1 change: 1 addition & 0 deletions src/web_performance/compression.conf
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"text/html" \
"text/javascript" \
"text/plain" \
"text/markdown" \
"text/vcard" \
"text/vnd.rim.location.xloc" \
"text/vtt" \
Expand Down
5 changes: 5 additions & 0 deletions src/web_performance/expires_headers.conf
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@
ExpiresByType text/cache-manifest "access plus 0 seconds"


# Markdown

ExpiresByType text/markdown "access plus 1 month"


# Media files

ExpiresByType audio/ogg "access plus 1 month"
Expand Down
5 changes: 5 additions & 0 deletions test/fixtures/test.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# test
test test test test test

## test test
test test test test test
5 changes: 5 additions & 0 deletions test/fixtures/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# test
test test test test test

## test test
test test test test test
12 changes: 12 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,18 @@ exports = module.exports = {
}
},

'test.markdown': {
responseHeaders: {
'content-type': 'text/markdown; charset=utf-8'
}
},

'test.md': {
responseHeaders: {
'content-type': 'text/markdown; charset=utf-8'
}
},

'test.mp4': {
responseHeaders: {
'content-encoding': null,
Expand Down

0 comments on commit bfcafd3

Please sign in to comment.