Operating on URLs.
Return a URL path composed of the given parts.
Specification:
parts (string): Arbitrary sequence of strings representing parts of a URL path.
Return value (string): Absolute or relative URL path.
Examples:
;;; Join the parts of a relative path. > (join-path «docs» «essays» «humanity.odt») «docs/essays/humanity.odt»
;;; Join the parts of an absolute path. > (join-path «» «en» «docs» «essays») «/en/docs/essays»
;;; Allow appending a slash at the end of the path. > (join-path «» «en» «docs» «essays» «») «/en/docs/essays/»
;;; A single empty string is interpreted as the path to the root. > (join-path «») «/»
Return the list of subpaths that lead to the path.
This function is useful for creating breadcrumbs from a URL path.
Specification:
path (string): URL path to a web resource.
Return value (list of strings): A list containing URL subpaths.
Examples:
> (path->subpaths «») '()
> (path->subpaths «docs/essays/moon»)
(list «docs/index.html»
«docs/essays/index.html»
«docs/essays/moon/index.html»)
> (path->subpaths «docs/essays/moon/»)
(list «docs/index.html»
«docs/essays/index.html»
«docs/essays/moon/index.html»)
> (path->subpaths «/docs/essays/moon/»)
(list «/index.html»
«/docs/index.html»
«/docs/essays/index.html»
«/docs/essays/moon/index.html»)
> (path->subpaths «docs/essays/moon/index.html»)
(list «docs/index.html»
«docs/essays/index.html»
«docs/essays/moon/index.html»)
> (path->subpaths «docs/essays/moon/image.png»)
(list «docs/index.html»
«docs/essays/index.html»
«docs/essays/moon/index.html»
«docs/essays/moon/image.png»)
Return text as an IRI slug.
Reserved characters for Internationalized Resource Identifiers (IRIs)
and common reserved characters for file names are removed using the
SLUG_FORBIDDEN constant as reference.
Specification:
text (string): Arbitrary text.
Return value (string): Slug-like string.
Example:
> (slugify «Biology») «biology»
> (slugify «Human anatomy») «human-anatomy»
Return a list of the components of the path.
Specification:
path (string): URL path to a web resource.
Return value (list of strings): A list with the components of
path.
Examples:
> (split-path «docs/essays/humanity.odt») (list «docs» «essays» «humanity.odt»)
> (split-path «/en/docs/essays») (list «» «en» «docs» «essays»)
> (split-path «/docs/essays/») (list «» «docs» «essays» «»)