dirname:function(path) {
return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, '');
},
+ /**
+ * Parses a string to an valid integer (unix timestamp)
+ * @param time
+ * @returns {*}
+ * @internal Only used to work around a bug in the backend
+ */
+ _parseTime: function(time) {
+ if (_.isString(time)) {
+ time = parseInt(time, 10);
+ if(isNaN(time)) {
+ time = null;
+ }
+ }
+ return time;
+ },
/**
* Displays the expiration date field
*
minDate: minDate,
maxDate: null
};
+ // TODO: hack: backend returns string instead of integer
+ shareTime = OC.Share._parseTime(shareTime);
if (_.isNumber(shareTime)) {
shareTime = new Date(shareTime * 1000);
}
});
// TODO: add unit tests for share recipients
});
+ describe('OC.Share utils', function() {
+ it('parseTime should properly parse strings', function() {
+
+ _.each([
+ [ '123456', 123456],
+ [ 123456 , 123456],
+ ['0123456', 123456],
+ ['abcdefg', null],
+ ], function(value) {
+ expect(OC.Share._parseTime(value[0])).toEqual(value[1]);
+ });
+
+ });
+ });
});