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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/common/TextUtils.js

Issue 1418293002: Devtools: Extensible mime typing, mime typing by file name (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add url function to mock project Created 5 years, 1 month 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 return text === text.toUpperCase(); 141 return text === text.toUpperCase();
142 }, 142 },
143 143
144 /** 144 /**
145 * @param {string} text 145 * @param {string} text
146 * @return {boolean} 146 * @return {boolean}
147 */ 147 */
148 isLowerCase: function(text) 148 isLowerCase: function(text)
149 { 149 {
150 return text === text.toLowerCase(); 150 return text === text.toLowerCase();
151 },
152
153 /**
154 * @param {string} text
155 * @param {string} delimiter
156 * @return {string}
157 */
158 _lastSectionBeforeQuery: function(text, delimiter)
159 {
160 var lastIndexOfDot = text.lastIndexOf(delimiter);
161 var extension = lastIndexOfDot !== -1 ? text.substr(lastIndexOfDot + 1) : "";
162 var indexOfQuestionMark = extension.indexOf("?");
163 if (indexOfQuestionMark !== -1)
164 extension = extension.substr(0, indexOfQuestionMark);
165 return extension;
166 },
167
168 /**
169 * @param {string} text
170 * @return {string}
171 */
172 extension: function(text)
173 {
174 return WebInspector.TextUtils._lastSectionBeforeQuery(text, ".");
175 },
176
177 /**
178 * @param {string} text
179 * @return {string}
180 */
181 fileName: function(text)
182 {
183 return WebInspector.TextUtils._lastSectionBeforeQuery(text, "/");
151 } 184 }
152 } 185 }
153 186
154 WebInspector.TextUtils._SpaceCharRegex = /\s/; 187 WebInspector.TextUtils._SpaceCharRegex = /\s/;
155 188
156 /** 189 /**
157 * @enum {string} 190 * @enum {string}
158 */ 191 */
159 WebInspector.TextUtils.Indent = { 192 WebInspector.TextUtils.Indent = {
160 TwoSpaces: " ", 193 TwoSpaces: " ",
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 */ 265 */
233 WebInspector.TokenizerFactory = function() { } 266 WebInspector.TokenizerFactory = function() { }
234 267
235 WebInspector.TokenizerFactory.prototype = { 268 WebInspector.TokenizerFactory.prototype = {
236 /** 269 /**
237 * @param {string} mimeType 270 * @param {string} mimeType
238 * @return {function(string, function(string, ?string, number, number))} 271 * @return {function(string, function(string, ?string, number, number))}
239 */ 272 */
240 createTokenizer: function(mimeType) { } 273 createTokenizer: function(mimeType) { }
241 } 274 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698