Skip to content
This repository has been archived by the owner on Apr 6, 2022. It is now read-only.

Warn about Link URLs with Tracking Params or Paywall Redirects #235

Open
tpreusse opened this issue Aug 28, 2020 · 3 comments
Open

Warn about Link URLs with Tracking Params or Paywall Redirects #235

tpreusse opened this issue Aug 28, 2020 · 3 comments

Comments

@tpreusse
Copy link
Contributor

Input from Dialog

Extend current URL validation to also warn about any utm params and abo.nzz.ch redirects.

@tpreusse
Copy link
Contributor Author

tpreusse commented Aug 28, 2020

Extend here:

visit(content, 'link', node => {
const urlObject = parse(node.url)
const warnings = []
const errors = []
if (!node.url || !node.url.trim()) {
errors.push('empty')
} else {
if (urlObject.path) {
if (
!urlObject.protocol &&
urlObject.path[0] !== '/' &&
urlObject.path[0] !== '#' &&
urlObject.path[0] !== '?'
) {
errors.push('relative')
}
if (urlObject.pathname.endsWith('.webp')) {
warnings.push('webp')
}
if (
(!urlObject.protocol || FRONTEND_HOSTNAME === urlObject.hostname) &&
urlObject.path.startsWith('/~')
) {
const slug = urlObject.pathname.split('~')[1]
if (!isUUID.v4(slug)) {
warnings.push('profiles')
}
}
}
if (urlObject.hostname) {
if (
urlObject.hostname.startsWith('ww.') ||
urlObject.hostname.startsWith('wwww.')
) {
warnings.push('wwwws')
}
}
}

@salim-b
Copy link

salim-b commented Aug 28, 2020

Maybe you could use the rules from Neat URL to strip tracking params :)

@caillou
Copy link

caillou commented Sep 18, 2020

There is an NPM package, also called neat-url. It was not updated since a year and is using the depricated URL.parse(). But the code is pretty straight forward https://gitlab.com/Cyprias/neat-url/-/blob/master/src/index.js

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants