MCPcopy
hub / github.com/vercel/next.js / deobfuscateModuleId

Function deobfuscateModuleId

packages/next/src/shared/lib/magic-identifier.ts:102–116  ·  view source on GitHub ↗
(moduleId: string)

Source from the content-addressed store, hash-verified

100 * - Removes content in brackets [], parentheses (), and angle brackets <>
101 */
102export function deobfuscateModuleId(moduleId: string): string {
103 return (
104 moduleId
105 // Replace [project] with .
106 .replace(/\[project\]/g, '.')
107 // Remove content in square brackets (e.g. [app-rsc])
108 .replace(/\s\[([^\]]*)\]/g, '')
109 // Remove content in parentheses (e.g. (ecmascript))
110 .replace(/\s\(([^)]*)\)/g, '')
111 // Remove content in angle brackets (e.g. <locals>)
112 .replace(/\s<([^>]*)>/g, '')
113 // Clean up any extra whitespace
114 .trim()
115 )
116}
117
118/**
119 * Removes the free call wrapper pattern (0, expr) from expressions.

Callers 2

deobfuscateTextPartsFunction · 0.85

Calls 2

trimMethod · 0.80
replaceMethod · 0.65

Tested by

no test coverage detected