@absolutejs/engagement-apollo 0.0.10 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +15 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11,6 +11,20 @@ var LOCKED_EMAIL = /email_not_unlocked/iu;
11
11
  var isRecord = (value) => typeof value === "object" && value !== null;
12
12
  var str = (value) => typeof value === "string" && value.length > 0 ? value : null;
13
13
  var num = (value) => typeof value === "number" && Number.isFinite(value) ? value : null;
14
+ var companyDomain = (org) => {
15
+ const primary = str(org.primary_domain);
16
+ if (primary)
17
+ return primary;
18
+ const website = str(org.website_url);
19
+ if (!website)
20
+ return null;
21
+ try {
22
+ const url = new URL(website);
23
+ return (url.protocol === "https:" || url.protocol === "http:") && !url.username && !url.password ? url.hostname.toLowerCase().replace(/^www\./u, "") || null : null;
24
+ } catch {
25
+ return null;
26
+ }
27
+ };
14
28
  var joinLocation = (parts) => {
15
29
  const present = parts.filter((part) => part !== null);
16
30
  return present.length > 0 ? present.join(", ") : null;
@@ -136,7 +150,7 @@ var apolloSource = (options) => {
136
150
  observedAt: new Date().toISOString()
137
151
  } : null,
138
152
  description: str(org.short_description),
139
- domain: str(org.primary_domain),
153
+ domain: companyDomain(org),
140
154
  employeeCount: num(org.estimated_num_employees),
141
155
  foundedYear: num(org.founded_year),
142
156
  industry: str(org.industry),
package/package.json CHANGED
@@ -44,7 +44,7 @@
44
44
  },
45
45
  "type": "module",
46
46
  "types": "./dist/index.d.ts",
47
- "version": "0.0.10",
47
+ "version": "0.0.11",
48
48
  "exports": {
49
49
  ".": {
50
50
  "types": "./dist/index.d.ts",