Skip to content

Commit

Permalink
HTML content negotiation now has 'no escape' flag set for anchors. Is…
Browse files Browse the repository at this point in the history
…sue #11.
  • Loading branch information
Matt Wallis committed Nov 17, 2016
1 parent 3f90377 commit d5ef09b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions generators/generate-htaccess.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@

# This script generates a .htaccess file for content negotiation according to the
# W3C Best Practice Recipes for Publishing RDF Vocabularies recipe4a
# https://www.w3.org/TR/swbp-vocab-pub/#recipe4a
# Some commented-out code from their example .htaccess file may persist here.
#
# The following command line parameters are substituted into the generated file.
$rewrite_base, $vocab_url_suffix, $vocab_rdf, $html_file = ARGV

$nargs = 4
raise "#{$0}: Wrong number of command line parameters. expected #{$nargs}." unless ARGV.size == $nargs

# CAUTION: Be really careful about escaping hashes that are intended to end up in a rewritten URL!
# Also the NE (no excape) part of [R=303,NE] is vital, or you end up with %23 in the URL instad of #.

puts <<-HERE
# This .htaccess file was generated by #{$0} with parameters:
# rewrite_base: #{$rewrite_base}
Expand Down Expand Up @@ -41,7 +49,7 @@
RewriteCond %{HTTP_ACCEPT} application/xhtml\+xml [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla/.*
#RewriteRule ^example4a/(.+) example4a-content/2005-10-31.html\#$1 [R=303,NE]
RewriteRule ^#{$vocab_url_suffix}/(.+) #{$html_file}\#$1 [R=303]
RewriteRule ^#{$vocab_url_suffix}/(.+) #{$html_file}\#$1 [R=303,NE]
# Rewrite rule to serve RDF/XML content from the namespace URI by default
#RewriteRule ^example4a/ example4a-content/2005-10-31.rdf [R=303]
Expand Down

0 comments on commit d5ef09b

Please sign in to comment.