url

Learn how to resolve a relative path into an absolute URL.

Resolves a relative path into an absolute URL based on the template location.

Example

The following template prints the resolved URL of a relative path:

template.json5
{  "$schema": "https://schema.croct.com/json/v1/template.json",  "title": "URL demo",  "description": "Prints the resolved URL of a relative path.",  "actions": [    {      "name": "print",      "message": "Resolved: ${url('./assets/config.json')}"    }  ]}

The url call resolves ./assets/config.json to its full URL based on where the template is hosted.

Parameters

path
string

The path to resolve, relative to the template.

Return

An absolute URL string.

For example, given a template hosted at:

https://github.com/acme/templates/blob/main/template.json5

Calling url('./assets/config.json') returns:

https://github.com/acme/templates/blob/main/assets/config.json