Merge pull request #135 from minrk/splitext

use splitext to remove extension from notebook name
This commit is contained in:
Thomas Kluyver 2015-06-08 17:04:08 -07:00
commit bb54245db5

View File

@ -1752,7 +1752,7 @@ define(function (require) {
* @return {string} This notebook's name (excluding file extension) * @return {string} This notebook's name (excluding file extension)
*/ */
Notebook.prototype.get_notebook_name = function () { 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; return nbname;
}; };
@ -2101,8 +2101,9 @@ define(function (require) {
* Returns the filename with the appropriate extension, appending if necessary. * Returns the filename with the appropriate extension, appending if necessary.
*/ */
Notebook.prototype.ensure_extension = function (name) { Notebook.prototype.ensure_extension = function (name) {
if (!name.match(/\.ipynb$/)) { var ext = utils.splitext(this.notebook_path)[1];
name = name + ".ipynb"; if (ext.length && name.slice(-ext.length) !== ext) {
name = name + ext;
} }
return name; return name;
}; };