Skip to content

Commit

Permalink
Merge pull request #34 from artsy/sailthr-script-fix-and-updates
Browse files Browse the repository at this point in the history
Sailthru script fix, and updates
  • Loading branch information
Ash Furrow authored Mar 2, 2020
2 parents 0d28dc2 + 58f9d90 commit faf724b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
22 changes: 11 additions & 11 deletions add-sailthru-paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,28 @@
* pattern was removed, it removes the corresponding encoded pattern.
*/

const fs = require("fs")
const fs = require('fs')

const filename = "apple-app-site-association.json"
const filename = 'apple-app-site-association.json'

function updateFile(block) {
const json = JSON.parse(fs.readFileSync(filename, { encoding: "utf8" }))
const json = JSON.parse(fs.readFileSync(filename, { encoding: 'utf8' }))
block(json)
fs.writeFileSync(filename, JSON.stringify(json, null, 2) + "\n", {
encoding: "utf8"
fs.writeFileSync(filename, JSON.stringify(json, null, 2) + '\n', {
encoding: 'utf8'
})
}

function unencodedPatterns(patterns) {
return patterns.filter(pattern => pattern.includes("/"))
return patterns.filter(pattern => pattern.includes('/'))
}

function encodePath(path) {
return path
.split("*")
.split('*')
.filter(component => component.length)
.map(component => new Buffer(component).toString("base64"))
.join("*")
.map(component => new Buffer(component).toString('base64'))
.join('*')
}

function isNotSailthruPattern(pattern) {
Expand All @@ -47,7 +47,7 @@ function isNotSailthruPattern(pattern) {
*/
function encodePattern(pattern) {
const path = pattern.match(/^NOT (.+)$/)[1]
const encoded = encodePath(path.slice(0, -(path.length % 3)))
const encoded = encodePath(path.slice(0, path.length - (path.length % 3)))
return `NOT *${encoded}*`
}

Expand All @@ -58,6 +58,6 @@ updateFile(json => {
...patterns.concat(
patterns.filter(isNotSailthruPattern).map(encodePattern)
),
"*"
'*'
]
})
9 changes: 9 additions & 0 deletions apple-app-site-association.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,28 @@
"NOT /venice-biennale*",
"NOT /gender-equality*",
"NOT /collections",
"NOT /log_in",
"NOT /sign_up",
"NOT /click/*/aHR0cHM6Ly9pdHVuZXMuYXBwbGUuY29tL3VzL3BvZGNhc3QvYXJ0c3kv*",
"NOT /click/*/aHR0cHM6Ly9hcnRzeS5uZXQv*",
"NOT /click/*/aHR0cHM6Ly9hcnRzeS50eXBlZm9ybS5j*",
"NOT /click/*/aHR0cHM6Ly9hcHAuYWRqdXN0LmNv*",
"NOT /users/auth/facebook/callback*",
"NOT /identity-verification*",
"NOT *L2FydGljbGVz*",
"NOT *L2FydGljbGUv*",
"NOT *L3Nlcmllcy8=*",
"NOT *L3ZpZGVv*",
"NOT *L25l*",
"NOT *L25ld3Mv*",
"NOT *L2VkaXRvcmlhbC8=*",
"NOT *LzIwMTYteWVhci1pbi1h*",
"NOT *L3ZlbmljZS1iaWVubmFs*",
"NOT *L2dlbmRlci1lcXVhbGl0*",
"NOT *L2NvbGxlY3Rpb25z*",
"NOT *L2xvZ19p*",
"NOT *L3NpZ25f*",
"NOT *L3VzZXJzL2F1dGgvZmFjZWJvb2svY2FsbGJhY2s=*",
"NOT *L2lkZW50aXR5LXZlcmlmaWNhdGlv*",
"*"
]
Expand Down

0 comments on commit faf724b

Please sign in to comment.