diff --git a/lib/filters.js b/lib/filters.js index f3237a0a..f4542083 100644 --- a/lib/filters.js +++ b/lib/filters.js @@ -50,13 +50,15 @@ export const refFilter = (data, { domain, domainOnly, raw }) => { const links = {}; const isValidRef = referrer => { - return ( - referrer !== '' && referrer !== null && !referrer.startsWith('/') && !referrer.startsWith('#') - ); + return referrer !== null && !referrer.startsWith('/') && !referrer.startsWith('#'); }; const cleanUrl = url => { try { + if (url === '') { + return 'direct'; + } + const { hostname, origin, pathname, searchParams, protocol } = new URL(url); if (regex.test(url)) {