Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Dependencies
node_modules
29 changes: 17 additions & 12 deletions gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class Gateway {
}

if ('hostedUrl' in request) {
requestSetting['hostedUrl'] = request['hostedUrl'];
requestSettings['hostedUrl'] = request['hostedUrl'];
delete (request['hostedUrl']);
} else {
requestSettings['hostedUrl'] = this.hostedUrl;
Expand Down Expand Up @@ -464,7 +464,7 @@ class Gateway {
}
}

ret = `
let ret = `
<form ${form_attrs}>
${form_fields}
</form>
Expand Down Expand Up @@ -506,7 +506,7 @@ class Gateway {
* @return string HTML containing <INPUT> tags
*/
function fieldToHtml(name, value) {
ret = '';
let ret = '';
if (typeof value === "object" && !Array.isArray(value)) {
Object.entries(value).forEach(([nestedKey, nestedValue]) => {
ret += fieldToHtml(`${name}[${nestedKey}]`, nestedValue);
Expand All @@ -528,25 +528,30 @@ function fieldToHtml(name, value) {
* (0x00 to 0x1f consists of whitespace and control characters)
*/
function ordEntities(str) {
return str.replace(/[(\x00-\x1f)]/g,
match => { return '&#' + match.codePointAt(0) + ';';
});
if (typeof str == 'string') {
return str.replace(/[(\x00-\x1f)]/g,
match => { return '&#' + match.codePointAt(0) + ';';
});
}
return str;
}

// https://stackoverflow.com/a/57448862
function htmlentities(str) {
if (typeof str == 'number') {
return str.toString();
}

return str.replace(/[&<>'"]/g,
tag => ({
if (typeof str == 'string') {
return str.replace(/[&<>'"]/g,
tag => ({
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
"'": '&#39;',
'"': '&quot;'
}[tag]));
}[tag]));
}
return str;
}

/**
Expand All @@ -565,8 +570,8 @@ function phpCompatibleSort(a, b) {

do {
// codePointAt helpfully returns undefined if pos > length
achr = a.codePointAt(pos);
bchr = b.codePointAt(pos);
let achr = a.codePointAt(pos);
let bchr = b.codePointAt(pos);

if (achr == undefined) { //We don't need to check b at all.
return -1
Expand Down
5 changes: 4 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"name": "cardstream-nodejs-sdk",
"version": "0.1.0",
"dependencies": {
"axios": "^0.21.1",
"chai": "^4.2.0",
Expand Down