mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-09 16:28:03 +03:00
Bug fix: referral_source should not become duplicated based on different case
Fixes https://github.com/TryGhost/Product/issues/3928
This commit is contained in:
parent
909c8b53a8
commit
3e8efcca90
@ -78,9 +78,10 @@ class ReferrerTranslator {
|
||||
// If referrer is from query params
|
||||
if (referrerSource) {
|
||||
const urlData = referrerUrl ? this.getDataFromUrl(referrerUrl) : null;
|
||||
const knownSource = Object.values(knownReferrers).find(referrer => referrer.source.toLowerCase() === referrerSource.toLowerCase());
|
||||
return {
|
||||
referrerSource: referrerSource,
|
||||
referrerMedium: referrerMedium || urlData?.medium || null,
|
||||
referrerSource: knownSource?.source || referrerSource,
|
||||
referrerMedium: knownSource?.medium || referrerMedium || urlData?.medium || null,
|
||||
referrerUrl: referrerUrl?.hostname ?? null
|
||||
};
|
||||
}
|
||||
|
@ -157,8 +157,22 @@ describe('ReferrerTranslator', function () {
|
||||
referrerUrl: null
|
||||
}
|
||||
])).eql({
|
||||
referrerSource: 'twitter',
|
||||
referrerMedium: null,
|
||||
referrerSource: 'Twitter',
|
||||
referrerMedium: 'social',
|
||||
referrerUrl: null
|
||||
});
|
||||
});
|
||||
|
||||
it('returns known source for ref source if exists', async function () {
|
||||
should(translator.getReferrerDetails([
|
||||
{
|
||||
referrerSource: 'facebook',
|
||||
referrerMedium: null,
|
||||
referrerUrl: null
|
||||
}
|
||||
])).eql({
|
||||
referrerSource: 'Facebook',
|
||||
referrerMedium: 'social',
|
||||
referrerUrl: null
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user