tests for _parseTime with hex and empty strings

This commit is contained in:
Morris Jobke 2015-07-28 14:20:55 +02:00
parent ebfbb97e66
commit 5a0d410488
2 changed files with 6 additions and 0 deletions

View File

@ -827,6 +827,10 @@ OC.Share={
*/
_parseTime: function(time) {
if (_.isString(time)) {
// skip empty strings and hex values
if (time === '' || (time.length > 1 && time[0] === '0' && time[1] === 'x')) {
return null;
}
time = parseInt(time, 10);
if(isNaN(time)) {
time = null;

View File

@ -1324,6 +1324,8 @@ describe('OC.Share tests', function() {
[ 123456 , 123456],
['0123456', 123456],
['abcdefg', null],
['0x12345', null],
[ '', null],
], function(value) {
expect(OC.Share._parseTime(value[0])).toEqual(value[1]);
});