@dargmuesli/nuxt-vio 3.0.0-beta.2 → 3.0.0-beta.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  export const SITE_NAME = 'Vio'
2
2
 
3
+ export const CACHE_VERSION = 'bOXMwoKlJr'
3
4
  export const COOKIE_PREFIX = SITE_NAME.toLocaleLowerCase()
4
5
  export const COOKIE_SEPARATOR = '_'
5
6
  export const FETCH_RETRY_AMOUNT = 3
@@ -80,6 +80,32 @@ export const getHost = (req: IncomingMessage) => {
80
80
  return req.headers.host
81
81
  }
82
82
 
83
+ export const getServiceHref = ({
84
+ host,
85
+ isSsr = true,
86
+ name,
87
+ port,
88
+ stagingHost,
89
+ }: {
90
+ host: string
91
+ isSsr?: boolean
92
+ name?: string
93
+ port?: number
94
+ stagingHost?: string
95
+ }) => {
96
+ const nameSubdomain = name?.replaceAll('_', '-')
97
+ const nameSubdomainString = nameSubdomain ? `${nameSubdomain}.` : ''
98
+ const portString = port ? `:${port}` : ''
99
+
100
+ if (stagingHost) {
101
+ return `https://${nameSubdomainString}${stagingHost}`
102
+ } else if (isSsr && process.server) {
103
+ return `http://${name}${portString}`
104
+ } else {
105
+ return `https://${nameSubdomainString}${getDomainTldPort(host)}`
106
+ }
107
+ }
108
+
83
109
  export const getTimezone = async (event: H3Event) =>
84
110
  getCookie(event, TIMEZONE_COOKIE_NAME) ||
85
111
  (