MCPcopy Create free account
hub / github.com/compilets/compilets / getFileNameFromModuleSpecifier

Function getFileNameFromModuleSpecifier

src/parser-utils.ts:90–100  ·  view source on GitHub ↗
(specifier: string)

Source from the content-addressed store, hash-verified

88 * For example, returns "export.ts" from "./export".
89 */
90export function getFileNameFromModuleSpecifier(specifier: string): string {
91 // Remove the ./ prefix.
92 if (specifier.startsWith('./'))
93 specifier = specifier.substr(2);
94 // Make sure the extension is .ts .
95 if (/\.[\w]+$/.test(specifier))
96 specifier = specifier.replace(/\.[\w]+$/, '.ts');
97 else
98 specifier += '.ts';
99 return specifier;
100}
101
102/**
103 * Calculate the node's namespace according to the file it is defined.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected