Apache .htaccess Tester
npm install @warren-bank/htaccess-testerjavascript
const htaccess_tester = require('@warren-bank/htaccess-tester')
const test_data = {
"url": "http://fdroid.example.com/repo/com.example.app/de/icon.png",
"htaccess": [
RewriteEngine on,
RewriteCond %{HTTP_REFERER} =http://example.com,
RewriteCond %{SSL:SSL_CIPHER_USEKEYSIZE} =128,
RewriteCond %{HTTP:ACCEPT} =text/plain,
RewriteCond expr "%{HTTP:AUTHORIZATION} == 'Basic %{ENV:BASIC_AUTHORIZATION}'",
RewriteRule "^(/?(?:repo|archive))/([^/]+)/[^/]+/icon.*\\.png$" "$1/icons/$2.png" [BCTLS,PT],
RewriteRule "^/?repo/icons(?:-\\d+)?/(com\\.example\\.app)(?:\\.\\d+)?\\.png$" "http://icons.example.com/$1/icon.png" [L,R=301]
],
"variables": {
"server": {
"HTTP_REFERER": "http://example.com"
},
"environment": {
"BASIC_AUTHORIZATION": "YWxhZGRpbjpvcGVuc2VzYW1l"
},
"ssl-environment": {
"SSL_CIPHER_USEKEYSIZE": "128"
},
"http-header": {
"ACCEPT": "text/plain",
"AUTHORIZATION": "Basic YWxhZGRpbjpvcGVuc2VzYW1l"
}
}
}
const test_results = htaccess_tester(test_data)
console.log(
JSON.stringify(test_results, null, 2)
)
`
__Output:__ log file
- - - -
#### Browser Build
__CDN links:__
* unpkg.com
* jsdelivr.net
__Usage:__
`html
`
__Example:__ HTML file → raw.githack.com
- - - -
#### Inspiration:
* library: htaccess-parser
- author: Mickael Burguet
- npm
- github
- license: MIT
- notes:
* this library serves as a foundation for converting lines of text in .htaccess file format to object models
* library: express-htaccess-middleware`