Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
Merge pull request #11 from uniquelyparticular/fix/mustache-token-rep…
Browse files Browse the repository at this point in the history
…lacement

Fix/mustache token replacement
  • Loading branch information
agrohs authored May 24, 2019
2 parents 2d52ae2 + 8f85745 commit 554f2b1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const sampleEndpoint = `https://12345678.ngrok.io/proxy/${encodeURIComponent(
$.ajax({
url: sampleEndpoint,
type: 'GET',
corse: true,
cors: true,
beforeSend: xhr => {
xhr.setRequestHeader(
'X-Shopify-Access-Token',
Expand Down
15 changes: 8 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { URL } = require('whatwg-url')
const UrlPattern = require('url-pattern')
const cors = require('micro-cors')()
const fetch = require('node-fetch')
const { filterByPrefix, mustachReplace } = require('./utils')
const { filterByPrefix, mustachReplace } = require('./utils/tokenization')

const _toJSON = error => {
return !error
Expand Down Expand Up @@ -48,18 +48,19 @@ const isWhitelisted = (host, hostMap) => {
}

const parseURL = url => {
const { host, protocol } = new URL(url)
return { host, protocol }
const { hostname, protocol } = new URL(url)
return { hostname, protocol }
}

const isAuthorized = (referer, whitelist = []) => {
// console.log('whitelist', whitelist)
const { host, protocol } = parseURL(referer)
// console.log('host', host)
const { hostname, protocol } = parseURL(referer)
// console.log('hostname', hostname)
// console.log('protocol', protocol)
return (
isWhitelisted(host, whitelist) &&
(protocol === 'https:' || (protocol === 'http:' && host === 'localhost'))
isWhitelisted(hostname, whitelist) &&
(protocol === 'https:' ||
(protocol === 'http:' && hostname === 'localhost'))
)
}

Expand Down
File renamed without changes.

0 comments on commit 554f2b1

Please sign in to comment.