deshortify
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -124,2 +124,8 @@ 'use strict'; | ||
var newUrl = resolveUrl(url, res.headers.location); | ||
if (this$1._rollbackUrl(newUrl)) { | ||
if (this$1._verbose) { | ||
console.log("rolling back: ", url, " ← ", newUrl); | ||
} | ||
return resolve(this$1._cleanUp(url)); | ||
} | ||
if (this$1._verbose && url !== newUrl) { | ||
@@ -263,6 +269,22 @@ console.log("follow: ", url, " → ", newUrl); | ||
host.match(/\.nytimes\.com$/) || // Infinite nocookies loop | ||
host.match(/^www\.amazon\.$/) || // 405 MethodNotAllowed | ||
host.match(/^www\.amazon\.$/) // 405 MethodNotAllowed | ||
); | ||
}; | ||
// Returns boolean true if the URL should be rolled back to the previous one, | ||
// false otherwise. | ||
// The goal is to avoid displaying URLs with obvious signs of being GPDR or | ||
// "no cookies" interstitials. | ||
Deshortifier.prototype._rollbackUrl = function _rollbackUrl (url) { | ||
var parsedUrl = parseUrl(url, true); | ||
var host = parsedUrl.host; | ||
var pathname = parsedUrl.pathname; | ||
return ( | ||
url.match(/\/authorize/) || // Potential paywall (e.g. nature.com) | ||
url.match(/subscribe/) || // Potential paywall | ||
url.match(/nocookie/) || // Potential paywall/login | ||
url.match(/gdpr/) // Potential "GDPR consent" interstitial | ||
url.match(/gdpr/) || // Potential "GDPR consent" interstitial | ||
(host === "www.bloomberg.com" && pathname.match(/^\/tosv2.html/)) // GPDR interstitial | ||
); | ||
@@ -269,0 +291,0 @@ }; |
{ | ||
"name": "deshortify", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "Turns short URLs into long, meaningful, crap-less URLs.", | ||
@@ -5,0 +5,0 @@ "main": "dist/deshortify.js", |
@@ -119,2 +119,8 @@ const http = require("http"); | ||
let newUrl = resolveUrl(url, res.headers.location); | ||
if (this._rollbackUrl(newUrl)) { | ||
if (this._verbose) { | ||
console.log("rolling back: ", url, " ← ", newUrl); | ||
} | ||
return resolve(this._cleanUp(url)); | ||
} | ||
if (this._verbose && url !== newUrl) { | ||
@@ -239,3 +245,3 @@ console.log("follow: ", url, " → ", newUrl); | ||
let host = parsedUrl.host; | ||
let { host } = parsedUrl; | ||
@@ -259,8 +265,23 @@ return ( | ||
host.match(/\.nytimes\.com$/) || // Infinite nocookies loop | ||
host.match(/^www\.amazon\.$/) || // 405 MethodNotAllowed | ||
host.match(/^www\.amazon\.$/) // 405 MethodNotAllowed | ||
); | ||
} | ||
// Returns boolean true if the URL should be rolled back to the previous one, | ||
// false otherwise. | ||
// The goal is to avoid displaying URLs with obvious signs of being GPDR or | ||
// "no cookies" interstitials. | ||
_rollbackUrl(url) { | ||
let parsedUrl = parseUrl(url, true); | ||
let { host, pathname } = parsedUrl; | ||
return ( | ||
url.match(/\/authorize/) || // Potential paywall (e.g. nature.com) | ||
url.match(/subscribe/) || // Potential paywall | ||
url.match(/nocookie/) || // Potential paywall/login | ||
url.match(/gdpr/) // Potential "GDPR consent" interstitial | ||
url.match(/gdpr/) || // Potential "GDPR consent" interstitial | ||
(host === "www.bloomberg.com" && pathname.match(/^\/tosv2.html/)) // GPDR interstitial | ||
); | ||
} | ||
} |
@@ -23,5 +23,9 @@ | ||
deshortifier.deshortify('https://www.linkedin.com/slink?code=dCDEzrN'); | ||
// deshortifier.deshortify('https://www.linkedin.com/slink?code=dCDEzrN'); | ||
// Should be rolled back | ||
// deshortifier.deshortify('https://www.bloomberg.com/news/articles/2019-06-10/salesforce-to-buy-tableau-for-15-3-billion-in-all-stock-deal'); | ||
deshortifier.deshortify('https://www.nature.com/articles/s41598-019-44557-w'); | ||
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
42971
539
4