Index: chrome/browser/resources/md_downloads/action_service.js |
diff --git a/chrome/browser/resources/md_downloads/action_service.js b/chrome/browser/resources/md_downloads/action_service.js |
index f984fe5a14614e3b853993e4dcaad33b70577641..70c5e59af948b83f9ccb65ea2f3976fab249d2bf 100644 |
--- a/chrome/browser/resources/md_downloads/action_service.js |
+++ b/chrome/browser/resources/md_downloads/action_service.js |
@@ -45,7 +45,7 @@ cr.define('downloads', function() { |
* (i.e. has a non-empty search term). |
*/ |
isSearching: function() { |
- return this.searchText_.length > 0; |
+ return (this.searchText_ || '').length > 0; |
asanka
2015/11/24 22:08:22
!!this.searchText_
or do you folks dislike that e
Dan Beam
2015/11/25 04:06:36
Done.
|
}, |
/** Opens the current local destination for downloads. */ |
@@ -78,9 +78,16 @@ cr.define('downloads', function() { |
this.searchText_ = searchText; |
- // Split quoted terms (e.g., 'The "lazy" dog' => ['The', 'lazy', 'dog']). |
+ /** |
+ * @param {string} s |
+ * @return {string} |s| without whitespace at the ends (trimmed). |
+ */ |
function trim(s) { return s.trim(); } |
- chrome.send('getDownloads', searchText.split(/"([^"]*)"/).map(trim)); |
+ |
+ // Split quoted terms (e.g., 'The "lazy" dog' => ['The', 'lazy', 'dog']). |
+ var terms = searchText ? searchText.split(/"([^"]*)"/).map(trim) : []; |
dpapad
2015/11/24 18:42:33
Is it worth adding tests for the regular expressio
Dan Beam
2015/11/25 04:06:36
Done.
|
+ |
+ chrome.send('getDownloads', terms); |
}, |
/** |