|
77 | 77 | var prev = entitlements[ASSOCIATED_DOMAINS]
|
78 | 78 | var next = updateAssociatedDomains(preferences)
|
79 | 79 |
|
80 |
| - prev = removePreviousAssociatedDomains(prev) |
| 80 | + prev = removePreviousAssociatedDomains(preferences, prev) |
81 | 81 | entitlements[ASSOCIATED_DOMAINS] = domains.concat(prev, next)
|
82 | 82 |
|
83 | 83 | return entitlements
|
84 | 84 | }
|
85 | 85 |
|
86 | 86 | // removed previous associated domains related to Branch (will not remove link domain changes from custom domains or custom sub domains)
|
87 |
| - function removePreviousAssociatedDomains (domains) { |
| 87 | + function removePreviousAssociatedDomains (preferences, domains) { |
88 | 88 | var output = []
|
| 89 | + var linkDomains = preferences.linkDomain |
| 90 | + |
89 | 91 | if (!domains) return output
|
90 | 92 | for (var i = 0; i < domains.length; i++) {
|
91 | 93 | var domain = domains[i]
|
92 |
| - if (domain.indexOf('bnc.lt') > 0 || domain.indexOf('app.link') > 0) continue |
93 |
| - output.push(domain) |
| 94 | + if (domain.indexOf('applinks:') === 0) { |
| 95 | + domain = domain.replace('applinks:', '') |
| 96 | + if (isBranchAssociatedDomains(domain, linkDomains)) { |
| 97 | + output.push('applinks:' + domain) |
| 98 | + } |
| 99 | + } else { |
| 100 | + if (isBranchAssociatedDomains(domain, linkDomains)) { |
| 101 | + output.push(domain) |
| 102 | + } |
| 103 | + } |
94 | 104 | }
|
95 | 105 |
|
96 | 106 | return output
|
97 | 107 | }
|
98 | 108 |
|
| 109 | + // determine if previous associated domain is related to Branch (to prevent duplicates when appending new) |
| 110 | + function isBranchAssociatedDomains (domain, linkDomains) { |
| 111 | + return !(domain.indexOf('bnc.lt') > 0 || domain.indexOf('app.link') > 0 || linkDomains.indexOf(domain) >= 0) |
| 112 | + } |
| 113 | + |
99 | 114 | // determine which Branch Link Domains to append
|
100 | 115 | function updateAssociatedDomains (preferences) {
|
101 | 116 | var domainList = []
|
|
0 commit comments