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

Side by Side Diff: Source/devtools/front_end/sdk/NetworkWorkspaceBinding.js

Issue 368643002: DevTools: Make addFileForURL more robust (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Compacting the malformed URL Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 /** 122 /**
123 * @param {string} url 123 * @param {string} url
124 * @param {!WebInspector.ContentProvider} contentProvider 124 * @param {!WebInspector.ContentProvider} contentProvider
125 * @param {boolean=} isContentScript 125 * @param {boolean=} isContentScript
126 * @return {!WebInspector.UISourceCode} 126 * @return {!WebInspector.UISourceCode}
127 */ 127 */
128 addFileForURL: function(url, contentProvider, isContentScript) 128 addFileForURL: function(url, contentProvider, isContentScript)
129 { 129 {
130 var splitURL = WebInspector.ParsedURL.splitURL(url); 130 var splitURL = WebInspector.ParsedURL.splitURL(url);
131 var projectName = splitURL[0]; 131 var projectName = splitURL[0];
132 var parentPath = decodeURI(splitURL.slice(1, splitURL.length - 1).join(" /")); 132 var parentPath = splitURL.slice(1, -1).join("/");
133 var name = decodeURI(splitURL[splitURL.length - 1]); 133 try {
134 parentPath = decodeURIComponent(parentPath);
vsevik 2014/07/02 12:43:40 We should use decodeURI here because of the differ
alph 2014/07/02 13:14:35 Done.
135 } catch (e) { }
136 var name = splitURL.peekLast() || "";
137 try {
138 name = decodeURIComponent(name);
139 } catch (e) { }
134 var projectDelegate = this._projectDelegate(projectName, isContentScript || false); 140 var projectDelegate = this._projectDelegate(projectName, isContentScript || false);
135 var path = projectDelegate.addFile(parentPath, name, url, contentProvide r); 141 var path = projectDelegate.addFile(parentPath, name, url, contentProvide r);
136 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (this._work space.uiSourceCode(projectDelegate.id(), path)); 142 var uiSourceCode = /** @type {!WebInspector.UISourceCode} */ (this._work space.uiSourceCode(projectDelegate.id(), path));
137 console.assert(uiSourceCode); 143 console.assert(uiSourceCode);
138 return uiSourceCode; 144 return uiSourceCode;
139 }, 145 },
140 146
141 reset: function() 147 reset: function()
142 { 148 {
143 for (var projectId in this._projectDelegates) 149 for (var projectId in this._projectDelegates)
144 this._projectDelegates[projectId].reset(); 150 this._projectDelegates[projectId].reset();
145 this._projectDelegates = {}; 151 this._projectDelegates = {};
146 }, 152 },
147 153
148 __proto__: WebInspector.Object.prototype 154 __proto__: WebInspector.Object.prototype
149 } 155 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698