Skip to content

Commit 0501a2f

Browse files
committed
fix donation link parsing
1 parent 94d1eb6 commit 0501a2f

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/utils/DonationLinkHelper.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@ public enum AffiliateService {
1515
AMAZON,
1616
}
1717

18-
1918
public static DonationService getDonatoinServiceByLink(String link) throws MalformedURLException {
20-
URL url = new URL(link);
19+
URL url = new URL(fixLink(link));
2120
switch (url.getHost()) {
2221
case "www.patreon.com":
2322
return DonationService.PATREON;
@@ -33,11 +32,17 @@ public static DonationService getDonatoinServiceByLink(String link) throws Malfo
3332
}
3433

3534
public static AffiliateService getAffiliateServiceByLink(String link) throws MalformedURLException {
36-
URL url = new URL(link);
35+
URL url = new URL(fixLink(link));
3736
switch (url.getHost()) {
3837
case "amzn.to": return AffiliateService.AMAZON;
3938
default: return AffiliateService.NO_AFILIATE;
4039
}
4140
}
4241

42+
private static String fixLink(String link) {
43+
return (link.startsWith("https://") || link.startsWith("http://"))
44+
? link
45+
: "https://" + link;
46+
}
47+
4348
}

0 commit comments

Comments
 (0)