Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1565)

Unified Diff: Source/devtools/front_end/common/TextUtils.js

Issue 1264133002: Devtools: [WIP] Implement enhanced devtools extension language APIs Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Small cleanups - prefer URIs to contentURLs, revert protocol unifications, remove lambdas Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..152bfc94b2e03e7fe4066246c9835c858b698448 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)
+ {
+ 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, "/");
}
}
« no previous file with comments | « Source/devtools/front_end/common/ResourceType.js ('k') | Source/devtools/front_end/components/ExecutionContextSelector.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698