Chromium Code Reviews| Index: Source/devtools/front_end/common/TextUtils.js |
| diff --git a/Source/devtools/front_end/common/TextUtils.js b/Source/devtools/front_end/common/TextUtils.js |
| index 2310478a50c4635b92e7d5122205c2b76a7f31ac..985363c2c0566169ac2bdf7612815f0ba05b864e 100644 |
| --- a/Source/devtools/front_end/common/TextUtils.js |
| +++ b/Source/devtools/front_end/common/TextUtils.js |
| @@ -148,6 +148,34 @@ WebInspector.TextUtils = { |
| isLowerCase: function(text) |
| { |
| return text === text.toLowerCase(); |
| + }, |
| + |
| + _lastSectionBeforeQuery: function(text, delimiter) |
|
pfeldman
2015/10/22 17:38:22
Annotate please.
wes
2015/10/23 19:00:41
Is it considered good practice to annotate all pri
|
| + { |
| + var lastIndexOfDot = text.lastIndexOf(delimiter); |
| + var extension = lastIndexOfDot !== -1 ? text.substr(lastIndexOfDot + 1) : ""; |
| + var indexOfQuestionMark = extension.indexOf("?"); |
| + if (indexOfQuestionMark !== -1) |
| + extension = extension.substr(0, indexOfQuestionMark); |
| + return extension; |
| + }, |
| + |
| + /** |
| + * @param {string} text |
| + * @return {string} |
| + */ |
| + extension: function(text) |
| + { |
| + return WebInspector.TextUtils._lastSectionBeforeQuery(text, "."); |
| + }, |
| + |
| + /** |
| + * @param {string} text |
| + * @return {string} |
| + */ |
| + fileName: function(text) |
| + { |
| + return WebInspector.TextUtils._lastSectionBeforeQuery(text, "/"); |
| } |
| } |