MCPcopy Index your code
hub / github.com/simstudioai/sim / extractCleanFilename

Function extractCleanFilename

apps/sim/lib/uploads/utils/file-utils.ts:882–896  ·  view source on GitHub ↗
(urlOrPath: string)

Source from the content-addressed store, hash-verified

880 * @returns Clean filename without query parameters
881 */
882export function extractCleanFilename(urlOrPath: string): string {
883 const withoutQuery = urlOrPath.split('?')[0]
884
885 try {
886 const url = new URL(
887 withoutQuery.startsWith('http') ? withoutQuery : `http://localhost${withoutQuery}`
888 )
889 const pathname = url.pathname
890 const filename = pathname.split('/').pop() || 'unknown'
891 return decodeURIComponent(filename)
892 } catch {
893 const filename = withoutQuery.split('/').pop() || 'unknown'
894 return decodeURIComponent(filename)
895 }
896}
897
898/**
899 * Extract workspaceId from execution file key pattern

Callers 1

route.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected