Skip to content
Closed
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
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Paystack.prototype = {
// Confirm user passed the argument to method
// and replace in endpoint

var match, index;
var match, index, argType;
for (var i=0;i<l;i++) {
match = argsInEndpoint[i].replace(/\W/g, '');
index = params.args.indexOf(match);
Expand All @@ -103,6 +103,10 @@ Paystack.prototype = {
}

// todo: args[index] must be string or int
argType = typeof args[index]
if ( argType !== 'string' && argType !== 'number' ) {
throw new Error("Resource declaration error -- id MUST be string or number e.g '1' or 1 ");
}
endpoint = endpoint.replace(new RegExp(argsInEndpoint[i]), args[index]);
args.splice(index, 1);
}
Expand Down