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

Method getFileHandler

src/lib/fileTypeHandler.js:65–81  ·  view source on GitHub ↗

* Get a file handler for a given filename * @param {string} filename * @returns {Object|null} The matching handler or null if none found

(filename)

Source from the content-addressed store, hash-verified

63 * @returns {Object|null} The matching handler or null if none found
64 */
65 getFileHandler(filename) {
66 const ext = filename.split(".").pop().toLowerCase();
67
68 for (const [id, handler] of this.#handlers) {
69 if (
70 handler.extensions.includes(ext) ||
71 handler.extensions.includes("*")
72 ) {
73 return {
74 id,
75 ...handler,
76 };
77 }
78 }
79
80 return null;
81 }
82
83 /**
84 * Get all registered handlers

Callers 1

openFile.jsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected