parseUrl
Generic URL parser. Extracts standard URL parts (domain, path, query) plus Prisme.ai-specific fields (workspaceId, file id/filename).| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
url | string | yes | Any URL (or raw string) |
| Field | Type | Description |
|---|---|---|
domain | string | Hostname (e.g. api.prisme.ai). Empty for non-URLs. |
path | string | Full pathname (e.g. /v2/files/ws123/abc.report.pdf). |
id | string | From the last path segment: everything before the first dot, only when 2+ dots are present. Empty otherwise. |
filename | string | From the last path segment: everything after the first dot. If no dot, equals the full segment. |
ext | string | Lowercase file extension from the filename (e.g. pdf, xlsx). Empty if none. |
workspaceId | string | Extracted from /files/{wsId}/… or /workspaces/{wsId}/…. Empty if not found. |
mimetype | string | MIME type inferred from the file extension. |
query | object | Query string parameters as key-value pairs. |
How id / filename splitting works
The last path segment is parsed based on the number of dots:
- 2+ dots (
{id}.{name}.{ext}):idis everything before the first dot,filenameis the rest. - 1 dot (
{name}.{ext}): the whole segment is thefilename, noid. - 0 dots: the whole segment is the
filename, noid.
| Last segment | id | filename |
|---|---|---|
abc123.report.pdf | abc123 | report.pdf |
doc.pdf | (empty) | doc.pdf |
README | (empty) | README |
Examples
Extract a file ID from a native upload 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 tochunkSize, maintains chunkOverlap between consecutive chunks, and recurses with finer separators for pieces still too large.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
content | string | string[] | yes | Text or array of texts to split | |
chunkSize | number | yes | Maximum size of each chunk (in characters) | |
chunkOverlap | number | yes | Number of overlapping characters between consecutive chunks | |
separators | string[] | no | ["\n\n", "\n", " ", ""] | Ordered list of separators to try, from coarsest to finest |
keepSeparator | boolean | "start" | "end" | no | false | Attach the separator to the chunk. true or "end" appends it to the preceding chunk, "start" prepends it to the following chunk. Only visible with non-whitespace separators (whitespace is trimmed). |
{ content, size } objects: