From 0501a2f543bab38be4a3722e1567d55d72997bb3 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Tue, 8 May 2018 21:58:35 +0200 Subject: [PATCH] fix donation link parsing --- .../newpipe/extractor/utils/DonationLinkHelper.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/utils/DonationLinkHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/utils/DonationLinkHelper.java index 04913225..817595ad 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/utils/DonationLinkHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/utils/DonationLinkHelper.java @@ -15,9 +15,8 @@ public class DonationLinkHelper { AMAZON, } - public static DonationService getDonatoinServiceByLink(String link) throws MalformedURLException { - URL url = new URL(link); + URL url = new URL(fixLink(link)); switch (url.getHost()) { case "www.patreon.com": return DonationService.PATREON; @@ -33,11 +32,17 @@ public class DonationLinkHelper { } public static AffiliateService getAffiliateServiceByLink(String link) throws MalformedURLException { - URL url = new URL(link); + URL url = new URL(fixLink(link)); switch (url.getHost()) { case "amzn.to": return AffiliateService.AMAZON; default: return AffiliateService.NO_AFILIATE; } } + private static String fixLink(String link) { + return (link.startsWith("https://") || link.startsWith("http://")) + ? link + : "https://" + link; + } + }