MCPcopy
hub / github.com/facebook/react / normalizeCodeLocInfo

Function normalizeCodeLocInfo

packages/internal-test-utils/consoleMock.js:148–169  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

146}
147
148function normalizeCodeLocInfo(str) {
149 if (typeof str !== 'string') {
150 return str;
151 }
152 // This special case exists only for the special source location in
153 // ReactElementValidator. That will go away if we remove source locations.
154 str = str.replace(/Check your code at .+?:\d+/g, 'Check your code at **');
155 // V8 format:
156 // at Component (/path/filename.js:123:45)
157 // React format:
158 // in Component (at filename.js:123)
159 return str.replace(/\n +(?:at|in) ([^(\[\n]+)[^\n]*/g, function (m, name) {
160 name = name.trim();
161 if (name.endsWith('.render')) {
162 // Class components will have the `render` method as part of their stack trace.
163 // We strip that out in our normalization to make it look more like component stacks.
164 name = name.slice(0, name.length - 7);
165 }
166 name = name.replace(/.*\/([^\/]+):\d+:\d+/, '**/$1:**:**');
167 return '\n in ' + name + ' (at **)';
168 });
169}
170
171function normalizeComponentStack(entry) {
172 if (

Callers 2

normalizeComponentStackFunction · 0.70
createLogAssertionFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected