mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-07 13:07:22 +08:00
add utils.splitext to js
mimic Python os.path.splitext
This commit is contained in:
parent
5ca1ad666d
commit
11013e648d
@ -384,6 +384,18 @@ IPython.utils = (function (IPython) {
|
||||
};
|
||||
|
||||
|
||||
var splitext = function (filename) {
|
||||
// mimic Python os.path.splitext
|
||||
// Returns ['base', '.ext']
|
||||
var idx = filename.lastIndexOf('.');
|
||||
if (idx > 0) {
|
||||
return [filename.slice(0, idx), filename.slice(idx)];
|
||||
} else {
|
||||
return [filename, ''];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// http://stackoverflow.com/questions/2400935/browser-detection-in-javascript
|
||||
var browser = (function() {
|
||||
var N= navigator.appName, ua= navigator.userAgent, tem;
|
||||
@ -403,6 +415,7 @@ IPython.utils = (function (IPython) {
|
||||
autoLinkUrls : autoLinkUrls,
|
||||
points_to_pixels : points_to_pixels,
|
||||
url_path_join : url_path_join,
|
||||
splitext : splitext,
|
||||
browser : browser
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user