Skip to content

Commit

Permalink
fix: getQueryString issue
Browse files Browse the repository at this point in the history
Closes #4
  • Loading branch information
SukkaW committed Jun 15, 2020
1 parent c384f8c commit 63b6082
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ async function senData(event, url, uuid, user_agent, page_url) {
const encode = (data) => encodeURIComponent(decodeURIComponent(data));

const getReqHeader = (key) => event.request.headers.get(key);
const getQueryString = (name) => {
const pattern = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i');
const r = url.search.substr(1).match(pattern);
return (r !== null) ? unescape(r[2]) : null;
};
const getQueryString = (name) => url.searchParams.get(name);

const reqParameter = {
headers: {
Expand Down Expand Up @@ -43,11 +39,11 @@ async function response(event) {

const Referer = getReqHeader('Referer');
const user_agent = getReqHeader('User-Agent');
const ref_host = (() => {
const ref_host = (() => {
try {
return new URL(Referer).hostname;
} catch (e) {
return ""
return ''
}
})();

Expand Down

0 comments on commit 63b6082

Please sign in to comment.