analytics/assets/js/dashboard/util/url.js

23 lines
653 B
JavaScript
Raw Normal View History

2021-07-22 08:56:42 +03:00
export function apiPath(site, path = '') {
return `/api/stats/${encodeURIComponent(site.domain)}${path}`
}
2021-11-26 12:41:41 +03:00
export function siteBasePath(site, path = '') {
return `/${encodeURIComponent(site.domain)}${path}`
}
2021-07-22 08:56:42 +03:00
export function sitePath(site, path = '') {
2021-11-29 13:30:19 +03:00
return siteBasePath(site, path) + window.location.search
}
export function setQuery(key, value) {
const query = new URLSearchParams(window.location.search)
query.set(key, value)
2021-09-27 17:16:25 +03:00
return `${window.location.pathname}?${query.toString()}`
}
export function externalLinkForPage(domain, page) {
const domainURL = new URL(`https://${domain}`)
return `https://${domainURL.host}${page}`
}