@288-toolkit/url

4.1.2 • Public • Published

Url

npm i @288-toolkit/url

A collection of functions to work with urls.

isExternalUrl()

Check if a URL is external.

validateSameOrigin()

Validate if the URL is from the same origin as the request URL.

createEntryUrlBuilder

Creates a function that builds URLs for entries.

const getEntryUrl = createEntryUrlBuilder({
	localize: true,
	siteUrl: 'https://example.org',
	homeUri: '__home__'
});

getEntryUrl(mockEntry).raw; // The URL object.
getEntryUrl(mockEntry).toAbsolute(); // Returns the full URL string.
getEntryUrl(mockEntry).toString(); // Returns the full URL string.
getEntryUrl(mockEntry).toSchemeLess(); // Returns the URL string without the scheme, composed of the pathname, search, and hash.
getEntryUrl(mockEntry).toLanguageRelative(); // Returns the entry uri relative to the language.

Readme

Keywords

none

Package Sidebar

Install

npm i @288-toolkit/url

Weekly Downloads

35

Version

4.1.2

License

MIT

Unpacked Size

5.74 kB

Total Files

14

Last publish

Collaborators

  • nitriques
  • f-elix