File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -158,7 +158,18 @@ export const facets = {
158
158
. filter ( ( evt ) => evt . checkpoint === 'enter' )
159
159
. map ( ( evt ) => evt . source )
160
160
. filter ( ( source ) => source )
161
- . map ( ( source ) => source . replace ( / \/ # $ / , '' ) )
161
+ . map ( ( source ) => {
162
+ try {
163
+ const url = new URL ( source ) ;
164
+ url . hash = '' ; // Remove the hash
165
+ return url . href ;
166
+ } catch ( e ) {
167
+ // eslint-disable-next-line no-console
168
+ console . error ( `Invalid URL: ${ source } ` ) ;
169
+ return null ;
170
+ }
171
+ } )
172
+ . filter ( ( source ) => source )
162
173
. map ( ( source ) => {
163
174
const referrerClass = classifyReferrer ( source ) ;
164
175
return referrerClass ? [
@@ -169,6 +180,7 @@ export const facets = {
169
180
] : source ;
170
181
} )
171
182
. flat ( ) ,
183
+
172
184
/**
173
185
* Extracts the target of the media view event from the bundle. This
174
186
* is typically the URL of an image or video, and the URL is stripped
You can’t perform that action at this time.
0 commit comments