MCPcopy
hub / github.com/retspen/webvirtcloud / normalizeModule

Function normalizeModule

static/js/ace.js:106–124  ·  view source on GitHub ↗
(parentId, moduleName)

Source from the content-addressed store, hash-verified

104};
105
106var normalizeModule = function(parentId, moduleName) {
107 // normalize plugin requires
108 if (moduleName.indexOf("!") !== -1) {
109 var chunks = moduleName.split("!");
110 return normalizeModule(parentId, chunks[0]) + "!" + normalizeModule(parentId, chunks[1]);
111 }
112 // normalize relative requires
113 if (moduleName.charAt(0) == ".") {
114 var base = parentId.split("/").slice(0, -1).join("/");
115 moduleName = base + "/" + moduleName;
116
117 while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
118 var previous = moduleName;
119 moduleName = moduleName.replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
120 }
121 }
122
123 return moduleName;
124};
125
126/**
127 * Internal function to lookup moduleNames and resolve them by calling the

Callers 1

lookupFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected