Add AnyClip integration tools and extracted source code
- Add authentication scripts with SubtleCrypto password encryption - Add sourcemap extraction pipeline (update-urls, download-sourcemaps, extract-sources) - Add Playwright API interception script for monetization endpoints - Document two-step auth flow with JWT tokens and dual cookies - Move extracted source from root to anyclip/ directory - Add project configuration (.env.example, .gitignore, CLAUDE.md)
This commit is contained in:
35
anyclip/client/get-domain-locale.ts
Normal file
35
anyclip/client/get-domain-locale.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import type { DomainLocale } from '../server/config'
|
||||
import type { normalizeLocalePath as NormalizeFn } from './normalize-locale-path'
|
||||
import type { detectDomainLocale as DetectFn } from './detect-domain-locale'
|
||||
import { normalizePathTrailingSlash } from './normalize-trailing-slash'
|
||||
|
||||
const basePath = (process.env.__NEXT_ROUTER_BASEPATH as string) || ''
|
||||
|
||||
export function getDomainLocale(
|
||||
path: string,
|
||||
locale?: string | false,
|
||||
locales?: readonly string[],
|
||||
domainLocales?: readonly DomainLocale[]
|
||||
) {
|
||||
if (process.env.__NEXT_I18N_SUPPORT) {
|
||||
const normalizeLocalePath: typeof NormalizeFn = (
|
||||
require('./normalize-locale-path') as typeof import('./normalize-locale-path')
|
||||
).normalizeLocalePath
|
||||
const detectDomainLocale: typeof DetectFn = (
|
||||
require('./detect-domain-locale') as typeof import('./detect-domain-locale')
|
||||
).detectDomainLocale
|
||||
|
||||
const target = locale || normalizeLocalePath(path, locales).detectedLocale
|
||||
const domain = detectDomainLocale(domainLocales, undefined, target)
|
||||
if (domain) {
|
||||
const proto = `http${domain.http ? '' : 's'}://`
|
||||
const finalLocale = target === domain.defaultLocale ? '' : `/${target}`
|
||||
return `${proto}${domain.domain}${normalizePathTrailingSlash(
|
||||
`${basePath}${finalLocale}${path}`
|
||||
)}`
|
||||
}
|
||||
return false
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user