MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / updateUriOfAllActiveFiles

Function updateUriOfAllActiveFiles

src/utils/helpers.js:274–292  ·  view source on GitHub ↗

* Updates uri of all active which matches the oldUrl as location * of the file * @param {String} oldUrl * @param {String} newUrl

(oldUrl, newUrl)

Source from the content-addressed store, hash-verified

272 * @param {String} newUrl
273 */
274 updateUriOfAllActiveFiles(oldUrl, newUrl) {
275 const files = editorManager.files;
276 const { url } = Url.parse(oldUrl);
277
278 for (let file of files) {
279 if (!file.uri) continue;
280 const fileUrl = Url.parse(file.uri).url;
281 if (new RegExp("^" + escapeStringRegexp(url)).test(fileUrl)) {
282 if (newUrl) {
283 file.uri = Url.join(newUrl, file.filename);
284 } else {
285 file.uri = null;
286 }
287 }
288 }
289
290 editorManager.onupdate("file-delete");
291 editorManager.emit("update", "file-delete");
292 },
293 canShowAds() {
294 return Boolean(!config.HAS_PRO && adRewards.canShowAds());
295 },

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected