Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade standard #24

Merged
merged 2 commits into from Jul 11, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Prev

Fix all errors and warnings from standard

This commit does not change the output of the script in any way.
  • Loading branch information
fmarier committed Jul 11, 2019
commit 9f03e40f63a80f4cf5e49214682165de8429831f
@@ -9,7 +9,7 @@ const exec = require('child_process').exec

const downloadRulesets = (dir, cb) => {
let timestamp = ''
let baseURL = 'https://www.https-rulesets.org/v1/'
const baseURL = 'https://www.https-rulesets.org/v1/'

// Obtain the latest rulesets timestamp from EFF's official endpoint
https.get(baseURL + 'latest-rulesets-timestamp', (response) => {
@@ -20,13 +20,13 @@ const downloadRulesets = (dir, cb) => {
// Download the rulesets once we obtained the timestamp
response.on('end', () => {
// ${timestamp} comes with trailing newlines, parse it and convert it back
let target = `default.rulesets.${Number(timestamp)}.gz`
const target = `default.rulesets.${Number(timestamp)}.gz`

https.get(baseURL + target, (stream) => {
// ${target} is gzipped, gunzip accordingly
// and pipe the output to ${filename}
let filename = path.join(dir, 'default.rulesets')
let output = fs.createWriteStream(filename)
const filename = path.join(dir, 'default.rulesets')
const output = fs.createWriteStream(filename)

stream.pipe(zlib.createGunzip()).pipe(output)

@@ -57,9 +57,9 @@ const buildDataFiles = () => {
rulesets = rulesets.rulesets
}

let jsonOutput = {
'rulesetStrings': [],
'targets': {}
const jsonOutput = {
rulesetStrings: [],
targets: {}
}

for (const ruleset of rulesets) {
@@ -76,13 +76,13 @@ const buildDataFiles = () => {
jsonOutput['targets'][target].push(jsonOutput['rulesetStrings'].length)
}

let r = {
const r = {
ruleset: {
'name': ruleset.name,
'rule': ruleset.rule.map((rule) => {
name: ruleset.name,
rule: ruleset.rule.map((rule) => {
return {
'from': rule.from,
'to': rule.to
from: rule.from,
to: rule.to
}
})
}
@@ -91,7 +91,7 @@ const buildDataFiles = () => {
if (ruleset.exclusion) {
r.exclusion = ruleset.exclusion.map((exclusion) => {
return {
'pattern': exclusion
pattern: exclusion
}
})
}
@@ -110,7 +110,7 @@ const buildDataFiles = () => {
compression: false, errorIfExists: true
})

let batch = httpseLevelDB.batch()
const batch = httpseLevelDB.batch()

for (const ruleset of rulesets) {
if (!ruleset.default_off && !ruleset.platform) {
@@ -120,7 +120,7 @@ const buildDataFiles = () => {
}

let targetRuleSets = []
let rule = {
const rule = {
r: ruleset.rule.map((rule) => {
if (rule.from === '^http:' && rule.to === 'https:') {
return { d: 1 }
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.