mirror of
https://github.com/plausible/analytics.git
synced 2024-12-21 00:21:43 +03:00
23 lines
653 B
JavaScript
23 lines
653 B
JavaScript
export function apiPath(site, path = '') {
|
|
return `/api/stats/${encodeURIComponent(site.domain)}${path}`
|
|
}
|
|
|
|
export function siteBasePath(site, path = '') {
|
|
return `/${encodeURIComponent(site.domain)}${path}`
|
|
}
|
|
|
|
export function sitePath(site, path = '') {
|
|
return siteBasePath(site, path) + window.location.search
|
|
}
|
|
|
|
export function setQuery(key, value) {
|
|
const query = new URLSearchParams(window.location.search)
|
|
query.set(key, value)
|
|
return `${window.location.pathname}?${query.toString()}`
|
|
}
|
|
|
|
export function externalLinkForPage(domain, page) {
|
|
const domainURL = new URL(`https://${domain}`)
|
|
return `https://${domainURL.host}${page}`
|
|
}
|