Skip to content

Commit b4fa5ee

Browse files
authored
Merge pull request #32 from adobe/issue-31
feat: normalise # in URLs for referrer classification
2 parents 0381bf7 + 1d7e6d3 commit b4fa5ee

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

facets.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export const facets = {
158158
.filter((evt) => evt.checkpoint === 'enter')
159159
.map((evt) => evt.source)
160160
.filter((source) => source)
161+
.map((source) => source.replace(/\/#$/, ''))
161162
.map((source) => {
162163
const referrerClass = classifyReferrer(source);
163164
return referrerClass ? [
@@ -192,7 +193,7 @@ export const facets = {
192193
}
193194
return u.toString();
194195
}),
195-
};
196+
};
196197

197198
/**
198199
* A facet function takes a bundle and returns an array of facet values.

test/facets.test.js

+5
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ describe('facets:enterSource', () => {
216216
assert.deepEqual(facets.enterSource({ events: [{ checkpoint: 'enter', source: 'https://www.google.com' }] }), ['https://www.google.com', 'search:google', 'search', '*:google']);
217217
});
218218

219+
it('enterSource:normalizeUrl', () => {
220+
assert.deepEqual(facets.enterSource({ events: [{ checkpoint: 'enter', source: 'https://www.example.com/#' }] }), ['https://www.example.com']);
221+
assert.deepEqual(facets.enterSource({ events: [{ checkpoint: 'enter', source: 'https://www.google.com/#' }] }), ['https://www.google.com', 'search:google', 'search', '*:google']);
222+
});
223+
219224
it('enterSource:DataChunks', () => {
220225
const d = new DataChunks();
221226
d.load(testChunks);

0 commit comments

Comments
 (0)