Generate correct date for AMZ credentials.

The old function was adding numbers together instead of strings. Convert
the numbers to strings before addition.
This commit is contained in:
Kyle Conroy
2015-10-27 22:09:49 -07:00
parent c0f57cddc9
commit d61394b041

View File

@@ -122,8 +122,8 @@ function getS3PolicyAndSig(domain, localPadId, userId) {
var expirationDate = new Date(); var expirationDate = new Date();
expirationDate.setDate(expirationDate.getDate() + 1); expirationDate.setDate(expirationDate.getDate() + 1);
function pad(n) { return n < 10 ? '0' + n : n } function pad(n) { return n < 10 ? '0' + n.toString() : n.toString() }
var utcDateStr = expirationDate.getUTCFullYear() + var utcDateStr = pad(expirationDate.getUTCFullYear()) +
pad(expirationDate.getUTCMonth() + 1) + pad(expirationDate.getUTCMonth() + 1) +
pad(expirationDate.getUTCDate()); pad(expirationDate.getUTCDate());