-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix domain name parsing on company creation (#4297)
* add domain parsing library * change package for psl * trying to fix error * fix * update * remove unused function
- Loading branch information
1 parent
aa7fa3a
commit 735e75b
Showing
6 changed files
with
28 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,8 @@ | |
"@ptc-org/nestjs-query-graphql": "patch:@ptc-org/[email protected]#./patches/@ptc-org+nestjs-query-graphql+4.2.0.patch", | ||
"class-validator": "patch:[email protected]#./patches/class-validator+0.14.0.patch", | ||
"graphql-middleware": "^6.1.35", | ||
"passport": "^0.7.0" | ||
"passport": "^0.7.0", | ||
"psl": "^1.9.0" | ||
}, | ||
"devDependencies": { | ||
"@nestjs/cli": "10.3.0", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 6 additions & 2 deletions
8
...ges/twenty-server/src/workspace/messaging/utils/get-company-name-from-domain-name.util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
import psl from 'psl'; | ||
|
||
import { capitalize } from 'src/utils/capitalize'; | ||
|
||
export const getCompanyNameFromDomainName = (domainName: string): string => { | ||
return capitalize(domainName.split('.').slice(-2, -1)[0]); | ||
export const getCompanyNameFromDomainName = (domainName: string) => { | ||
const { sld } = psl.parse(domainName); | ||
|
||
return sld ? capitalize(sld) : ''; | ||
}; |
12 changes: 9 additions & 3 deletions
12
packages/twenty-server/src/workspace/messaging/utils/get-domain-name-from-handle.util.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
export function getDomainNameFromHandle(handle: string): string { | ||
return handle.split('@')?.[1].split('.').slice(-2).join('.').toLowerCase(); | ||
} | ||
import psl from 'psl'; | ||
|
||
export const getDomainNameFromHandle = (handle: string): string => { | ||
const wholeDomain = handle?.split('@')?.[1] || ''; | ||
|
||
const { domain } = psl.parse(wholeDomain); | ||
|
||
return domain || ''; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38834,7 +38834,7 @@ __metadata: | |
languageName: node | ||
linkType: hard | ||
|
||
"psl@npm:^1.1.28, psl@npm:^1.1.33": | ||
"psl@npm:^1.1.28, psl@npm:^1.1.33, psl@npm:^1.9.0": | ||
version: 1.9.0 | ||
resolution: "psl@npm:1.9.0" | ||
checksum: 6a3f805fdab9442f44de4ba23880c4eba26b20c8e8e0830eff1cb31007f6825dace61d17203c58bfe36946842140c97a1ba7f67bc63ca2d88a7ee052b65d97ab | ||
|
@@ -44289,6 +44289,7 @@ __metadata: | |
class-validator: "patch:[email protected]#./patches/class-validator+0.14.0.patch" | ||
graphql-middleware: "npm:^6.1.35" | ||
passport: "npm:^0.7.0" | ||
psl: "npm:^1.9.0" | ||
rimraf: "npm:^5.0.5" | ||
typescript: "npm:^5.3.3" | ||
languageName: unknown | ||
|