Skip to content

A quick script to parse HTTPS Everywhere’s rewriting rules

License

Notifications You must be signed in to change notification settings

bfontaine/tohttps.rb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tohttps

This is a quick script to parse HTTPS Everywhere’s rules

Usage

Clone their repo somewhere on your computer:

git clone https://github.com/EFForg/https-everywhere.git

And this one:

git clone https://github.com/bfontaine/tohttps.rb.git && cd tohttps.rb

Then load a rule like this:

require "./tohttps"

# replace with a valid filepath
r = Ruleset.new File.read("path/to/https-everywhere/rules/the-rule.xml")

# check if a URL matches the rule
r.match? "http://example.com/foo"

# rewrite a URL using the rule
r.replace "http://example.com/foo"

# load all the rules from a directory (warning: it takes a few minutes)
b = BatchRuleset.new "path/to/https-everywhere/rules"

# returns the first rule matched by the URL
b.ruleset_for "http://example.com"

Note: this is a quick & dirty script for now, it doesn’t have unit tests nor documentation, and could really be optimized. I might make a gem at some point in the future.

About

A quick script to parse HTTPS Everywhere’s rewriting rules

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages