MCPcopy Create free account
hub / github.com/vercel/vercel / sanitizeConsumerName

Function sanitizeConsumerName

packages/build-utils/src/lambda.ts:36–53  ·  view source on GitHub ↗
(functionPath: string)

Source from the content-addressed store, hash-verified

34 * sanitizeConsumerName('my_func.ts') // => 'my__func_Dts'
35 */
36export function sanitizeConsumerName(functionPath: string): string {
37 let result = '';
38 for (const char of functionPath) {
39 if (char === '_') {
40 result += '__';
41 } else if (char === '/') {
42 result += '_S';
43 } else if (char === '.') {
44 result += '_D';
45 } else if (/[A-Za-z0-9-]/.test(char)) {
46 result += char;
47 } else {
48 result +=
49 '_' + char.charCodeAt(0).toString(16).toUpperCase().padStart(2, '0');
50 }
51 }
52 return result;
53}
54
55export type LambdaOptions = LambdaOptionsWithFiles | LambdaOptionsWithZipBuffer;
56

Callers 5

unit.test.tsFile · 0.90
buildFunction · 0.90

Calls 2

testMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected