We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c3a2c90 commit 59b94e5Copy full SHA for 59b94e5
packages/generator/index.ts
@@ -35,9 +35,9 @@ function addConfig(module: string, base: string) {
35
36
const url = new URL(base)
37
const hostname = url.hostname
38
- const parts = hostname.split('.')
39
- const mainDomain = parts.slice(-3).join('.') // 拿到根域名
40
- // 检查一下 hostnames 里面有没有这个根域名,没有的话就加进去
+ const regex = /(?:https?:\/\/)?(?:www\.)?([^\/]+)\/?.*/
+ const mainDomain = hostname.match(regex)?.[1] || hostname
+ // 检查一下 hostnames 里面有没有这个域名,没有的话就加进去
41
if (!hostnames.includes(`${mainDomain}`))
42
hostnames.push(`${mainDomain}`)
43
0 commit comments