Skip to content

Class: UtilsUrl ​

URL utilities: cleanly assembling segments into a single URL.

Remarks ​

Accessible everywhere via k.Utils.Url. All methods are static.

Example ​

ts
k.Utils.Url.joinUrl('https://api.example.com/', '/v1/', 'users');
// → "https://api.example.com/v1/users"

Constructors ​

Constructor ​

ts
new UtilsUrl(): UtilsUrl;

Returns ​

UtilsUrl

Methods ​

joinUrl() ​

ts
static joinUrl(...parts): string;

Assembles several segments into a URL while handling slashes: empty segments are ignored and superfluous / at the start/end of a segment are removed to avoid duplicates (//).

Parameters ​

parts ​

...string[]

The URL segments to concatenate, in order.

Returns ​

string

The assembled URL, with segments joined by a single /.

Remarks ​

The first segment keeps its prefix (e.g. https://); only its trailing / are stripped.

Example ​

ts
k.Utils.Url.joinUrl('/api', 'v1/', '/items');
// → "/api/v1/items"