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

Commit 554f2b1

Browse files
authored
Merge pull request #11 from uniquelyparticular/fix/mustache-token-replacement
Fix/mustache token replacement
2 parents 2d52ae2 + 8f85745 commit 554f2b1

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ const sampleEndpoint = `https://12345678.ngrok.io/proxy/${encodeURIComponent(
8888
$.ajax({
8989
url: sampleEndpoint,
9090
type: 'GET',
91-
corse: true,
91+
cors: true,
9292
beforeSend: xhr => {
9393
xhr.setRequestHeader(
9494
'X-Shopify-Access-Token',

src/index.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const { URL } = require('whatwg-url')
55
const UrlPattern = require('url-pattern')
66
const cors = require('micro-cors')()
77
const fetch = require('node-fetch')
8-
const { filterByPrefix, mustachReplace } = require('./utils')
8+
const { filterByPrefix, mustachReplace } = require('./utils/tokenization')
99

1010
const _toJSON = error => {
1111
return !error
@@ -48,18 +48,19 @@ const isWhitelisted = (host, hostMap) => {
4848
}
4949

5050
const parseURL = url => {
51-
const { host, protocol } = new URL(url)
52-
return { host, protocol }
51+
const { hostname, protocol } = new URL(url)
52+
return { hostname, protocol }
5353
}
5454

5555
const isAuthorized = (referer, whitelist = []) => {
5656
// console.log('whitelist', whitelist)
57-
const { host, protocol } = parseURL(referer)
58-
// console.log('host', host)
57+
const { hostname, protocol } = parseURL(referer)
58+
// console.log('hostname', hostname)
5959
// console.log('protocol', protocol)
6060
return (
61-
isWhitelisted(host, whitelist) &&
62-
(protocol === 'https:' || (protocol === 'http:' && host === 'localhost'))
61+
isWhitelisted(hostname, whitelist) &&
62+
(protocol === 'https:' ||
63+
(protocol === 'http:' && hostname === 'localhost'))
6364
)
6465
}
6566

File renamed without changes.

0 commit comments

Comments
 (0)