url fields and methods A field is a plain fact about the value, read with a dot and no brackets: $value.name. A method takes arguments or does work, and is called with ->: $value->name(arguments), or with the value piped in: $value |> name(arguments).
Fields Field Type Description .fragmentstring The part after #, without it. .hoststring The host name, in lower case: example.com. .originstring The scheme, host and any port written: https://example.com . .pathstring The path, starting with /: /docs/start. .portnumber The port: the one written, or the scheme's usual one (443 for https). .querymap The query string as a map: ?page=2&q=cats gives { page: '2', q: 'cats' }. .schemestring The scheme, in lower case: https.
From KScript.Core # url ->join (path: string ) → url The url a link to path leads to from here: ../img/a.png or /about.
Parameter Takes path required string
Example
.kscript XML Copy
<let name="x" type="url" value="'https://example.com:8443/docs?page=2#intro'" />
<echo>{ $x->join('../blog/') }</echo>.kscript XML Copy
$x: url = 'https://example.com:8443/docs?page=2#intro'
echo $x->join('../blog/')# url ->with (path?: string , query?: map , fragment?: string ) → url The url with parts changed: a new path, query values added or replaced (null removes one), or a new fragment (empty removes it). ->with(path: '/docs', query: { page: 3 }).
Arguments can be named: ->with(…, query: …, fragment: …).
Example
.kscript XML Copy
<let name="x" type="url" value="'https://example.com:8443/docs?page=2#intro'" />
<echo>{ $x->with(path: '/blog/', query: { page: 3 }, fragment: 'top') }</echo>.kscript XML Copy
$x: url = 'https://example.com:8443/docs?page=2#intro'
echo $x->with(path: '/blog/', query: { page: 3 }, fragment: 'top')# url ->without (query?: bool|string[] , fragment?: bool ) → url The url without parts: the whole query or fragment (->without(query, fragment)), or only some query values (->without(query: ['page'])).
Parameter Takes query optional bool|string[] fragment optional a flag: fragment or not fragment
Arguments can be named: ->without(…, fragment: …).
Example
.kscript XML Copy
<let name="x" type="url" value="'https://example.com:8443/docs?page=2#intro'" />
<echo>{ $x->without(query, fragment) } { $x->without(query: ['page']) }</echo>.kscript XML Copy
$x: url = 'https://example.com:8443/docs?page=2#intro'
echo "{ $x->without(query, fragment) } { $x->without(query: ['page']) }"Methods from any Methods from string ->contains(text, ignore_case?: bool)->count()->ends_with(text, ignore_case?: bool)->escape()->index_of(text, ignore_case?: bool, last?: bool)->markdown_escape()->matches(pattern: regex)->pad(width: number, char?, start?: bool)->replace(old, new, ignore_case?: bool)->slice(start: number, end?: number)->split(separator?)->starts_with(text, ignore_case?: bool)->truncate(length: number, suffix?)->url_encode()