Skip to content

Commit

Permalink
make sure filename_ext is defined. Make sure file is defined and thro…
Browse files Browse the repository at this point in the history
…w an error
  • Loading branch information
jrchudy committed Mar 28, 2024
1 parent e32f76d commit 8109479
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/hatrac.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,9 @@ var ERMrest = (function(module) {
this.CHUNK_QUEUE_SIZE = otherInfo.chunkQueueSize || 4;

this.file = file;
this.storedFilename = file.name; // the name that will be used for content-disposition and filename column
if (!this.file) throw new Error("No file provided while creating hatrac file object");

this.storedFilename = file.name; // the name that will be used for content-disposition and filename column
if (isNode) this.file.buffer = require('fs').readFileSync(file.path);

this.column = otherInfo.column;
Expand Down Expand Up @@ -841,7 +842,7 @@ var ERMrest = (function(module) {
// For example if we have a file named "file.tar.zip"
// => "file.tar" is the basename
// => ".zip" is the extension
row[this.column.name].filename_basename = this.file.name.substring(0, this.file.name.indexOf(filename_ext));
row[this.column.name].filename_basename = filename_ext ? this.file.name.substring(0, this.file.name.length - filename_ext.length) : this.file.name;

// Generate url

Expand Down

0 comments on commit 8109479

Please sign in to comment.