htaccess/no-rawgit
Severity: error · Status: enforced · Applies to: ids/**/.htaccess
What
A redirect target must not use rawgit.com or cdn.rawgit.com. Use jsDelivr for files, or GitHub Pages for pages meant to be read.
Why
RawGit has shut down. Its repository is archived, with a notice to use jsDelivr instead.
rawgit.comreturns 404. An identifier redirecting there does not resolve.cdn.rawgit.comonly forwards to jsDelivr. It works today because a shut-down service still answers, and it can stop without notice.
jsDelivr serves the same files from GitHub, and it is what RawGit's notice points to. It also sends a real content type for RDF — text/turtle, application/rdf+xml, application/ld+json — which raw.githubusercontent.com does not.
Wrong
RewriteRule ^vocab$ https://rawgit.com/user/repo/master/vocab.ttl [R=303,L]
RewriteRule ^vocab$ https://cdn.rawgit.com/user/repo/v1.0/vocab.ttl [R=303,L]Right
RewriteRule ^vocab$ https://cdn.jsdelivr.net/gh/user/repo@v1.0/vocab.ttl [R=303,L]How to fix
Move the ref after an @:
https://rawgit.com/user/repo/REF/path/file.ttl
https://cdn.rawgit.com/user/repo/REF/path/file.ttl
https://cdn.jsdelivr.net/gh/user/repo@REF/path/file.ttlThe finding names the exact URL to use. Check that it returns the file and the content type you expect:
curl -sIL https://cdn.jsdelivr.net/gh/user/repo@v1.0/vocab.ttl \
| grep -iE '^(HTTP|content-type)'Two things to know about jsDelivr:
- It serves HTML as
text/plain, so a browser shows the source. For a documentation page, use the repository's GitHub Pages site instead. - It caches a branch, so a push to
mastercan take a while to appear. A URL naming a tag or a commit always serves the same file.
How to check
Run w3id-check with --rule htaccess/no-rawgit to check this rule on its own; without it the tool runs every rule, as the pull request checks do.
node tools/check/bin/w3id-check.js --rule htaccess/no-rawgit ids/my-projectThis is a critical rule, so w3id-check --triage lists every identifier in the tree that still uses RawGit.
Testing your changes covers installing the tool, and what else is worth checking by hand.