@dargmuesli/nuxt-vio 13.1.7 → 13.1.9
Sign up to get free protection for your applications and to get access to all the features.
package/package.json
CHANGED
@@ -57,7 +57,7 @@
|
|
57
57
|
"stylelint-no-unsupported-browser-features": "8.0.1",
|
58
58
|
"tailwindcss": "3.4.4",
|
59
59
|
"unhead": "1.9.14",
|
60
|
-
"vue": "3.4.
|
60
|
+
"vue": "3.4.31",
|
61
61
|
"vue-router": "4.4.0"
|
62
62
|
},
|
63
63
|
"engines": {
|
@@ -87,7 +87,7 @@
|
|
87
87
|
"name": "@dargmuesli/nuxt-vio",
|
88
88
|
"peerDependencies": {
|
89
89
|
"nuxt": "3.12.2",
|
90
|
-
"vue": "3.4.
|
90
|
+
"vue": "3.4.31",
|
91
91
|
"vue-router": "4.4.0"
|
92
92
|
},
|
93
93
|
"publishConfig": {
|
@@ -116,5 +116,5 @@
|
|
116
116
|
"start:static": "serve .playground/.output/public --ssl-cert ./.config/certificates/ssl.crt --ssl-key ./.config/certificates/ssl.key"
|
117
117
|
},
|
118
118
|
"type": "module",
|
119
|
-
"version": "13.1.
|
119
|
+
"version": "13.1.9"
|
120
120
|
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { H3Event } from 'h3'
|
2
|
+
import { TESTING_COOKIE_NAME } from '../../utils/constants'
|
3
|
+
|
4
|
+
export const isTestingServer = (event?: H3Event) => {
|
5
|
+
const isTestingByRuntimeConfig = useRuntimeConfig().public.vio.isTesting
|
6
|
+
|
7
|
+
if (isTestingByRuntimeConfig) return true
|
8
|
+
|
9
|
+
if (event) {
|
10
|
+
const isTestingByCookie = !!getCookie(event, TESTING_COOKIE_NAME)
|
11
|
+
|
12
|
+
if (isTestingByCookie) return true
|
13
|
+
}
|
14
|
+
}
|
package/server/utils/timezone.ts
CHANGED
@@ -12,11 +12,9 @@ export const getTimezoneServer = async (event: H3Event) => {
|
|
12
12
|
|
13
13
|
if (timezoneByCookie) return timezoneByCookie
|
14
14
|
|
15
|
-
const ip = event
|
15
|
+
const ip = getRequestIP(event, { xForwardedFor: true })
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
if (ip && !Array.isArray(ip)) {
|
17
|
+
if (ip) {
|
20
18
|
const timezoneByIpApi = await getTimezoneByIpApi(ip)
|
21
19
|
|
22
20
|
if (timezoneByIpApi) return timezoneByIpApi
|
@@ -24,6 +22,8 @@ export const getTimezoneServer = async (event: H3Event) => {
|
|
24
22
|
}
|
25
23
|
|
26
24
|
export const getTimezoneByIpApi = async (ip: string) => {
|
25
|
+
if (isTestingServer()) return // TODO: mock
|
26
|
+
|
27
27
|
const ipApiResult = await $fetch<{ timezone: string }>(
|
28
28
|
`http://ip-api.com/json/${ip}`,
|
29
29
|
).catch(() => {})
|
package/utils/constants.ts
CHANGED
@@ -156,6 +156,7 @@ export const POLYFILLS = [
|
|
156
156
|
]
|
157
157
|
export const REGEX_UUID =
|
158
158
|
/^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$/
|
159
|
+
export const TESTING_COOKIE_NAME = 'vio_is-testing'
|
159
160
|
export const TIMEZONE_COOKIE_NAME = [COOKIE_PREFIX, 'tz'].join(COOKIE_SEPARATOR)
|
160
161
|
export const TIMEZONE_HEADER_KEY = `X-${SITE_NAME}-Timezone`
|
161
162
|
export const TITLE_TEMPLATE = ({
|