Skip to content

Commit

Permalink
Merge pull request #135 from minrk/splitext
Browse files Browse the repository at this point in the history
use splitext to remove extension from notebook name
  • Loading branch information
takluyver committed Jun 9, 2015
2 parents c85fb52 + 925da82 commit bb54245
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions notebook/static/notebook/js/notebook.js
Original file line number Diff line number Diff line change
Expand Up @@ -1752,7 +1752,7 @@ define(function (require) {
* @return {string} This notebook's name (excluding file extension)
*/
Notebook.prototype.get_notebook_name = function () {
var nbname = this.notebook_name.substring(0,this.notebook_name.length-6);
var nbname = utils.splitext(this.notebook_name)[0];
return nbname;
};

Expand Down Expand Up @@ -2101,8 +2101,9 @@ define(function (require) {
* Returns the filename with the appropriate extension, appending if necessary.
*/
Notebook.prototype.ensure_extension = function (name) {
if (!name.match(/\.ipynb$/)) {
name = name + ".ipynb";
var ext = utils.splitext(this.notebook_path)[1];
if (ext.length && name.slice(-ext.length) !== ext) {
name = name + ext;
}
return name;
};
Expand Down

0 comments on commit bb54245

Please sign in to comment.