Skip to main content
The text module provides pure-JS text processing utilities, with no external dependencies.

parseUrl

Generic URL parser. Extracts standard URL parts (domain, path, query) plus Prisme.ai-specific fields (workspaceId, file id/filename).
Returns an object with the following fields:

How id / filename splitting works

The last path segment is parsed based on the number of dots:
  • 2+ dots ({id}.{name}.{ext}): id is everything before the first dot, filename is the rest.
  • 1 dot ({name}.{ext}): the whole segment is the filename, no id.
  • 0 dots: the whole segment is the filename, no id.

Examples

Extract a file ID from a native upload URL:
Extract workspace ID from any Prisme.ai URL:

splitText

Split text into chunks using a recursive character splitting strategy. The splitter tries separators in order, splits on the first one found, merges small pieces back up to chunkSize, maintains chunkOverlap between consecutive chunks, and recurses with finer separators for pieces still too large.
Returns an array of { content, size } objects:

Split with custom separators (e.g. Markdown headings)

Iterate over chunks