WebLocations

Package: Libraries.Web · Inherits from: Libraries.Language.Object

WebLocations holds the one rule every location on a website follows: a location is always inside the site, so it never starts with a slash and never uses ".." to climb out of its folder. With that rule, "style/site.css" can only mean one place; there is no "/style/site.css" that means something else. It also joins a folder and a location the same way everywhere. It is a shared class, so there is only one.

Example Code

use Libraries.Web.WebLocations

WebLocations locations
locations:Check("tutorials/start.html")
output locations:Join("html", "tutorials/start.html")

Actions

Check(text location)

Stops the build with a clear message if a location breaks the rule: it starts with a slash, or uses ".." to leave its folder.

Parameters

  • location text: A location, such as "tutorials/start.html".

FromSiteTop(text location)

Returns a location as a browser asks for it, from the top of the site: "style/site.css" becomes "/style/site.css". Only the site adds this slash; people never write it.

Parameters

  • location text: A location, such as "style/site.css".

Returns

text: The location with one leading slash.

Join(text folder, text location)

Joins a folder and a location inside it, with one slash between them, whether or not the folder ends with one.

Parameters

  • folder text: A folder, such as "html" or "html/".
  • location text: A location inside it, such as "media/a.csv".

Returns

text: The two joined, such as "html/media/a.csv".

Inherited Actions

3 actions from Libraries.Language.Object