From 16d05d55e004158e28ea43f74f9f092741ef7aca Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Fri, 19 Apr 2013 20:07:30 +0200 Subject: [PATCH] Resolve relative comic URIs against base URI. --- .../net/pterodactylus/rhynodge/filters/ComicSiteFilter.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/pterodactylus/rhynodge/filters/ComicSiteFilter.java b/src/main/java/net/pterodactylus/rhynodge/filters/ComicSiteFilter.java index 9b3dfcd..6643745 100644 --- a/src/main/java/net/pterodactylus/rhynodge/filters/ComicSiteFilter.java +++ b/src/main/java/net/pterodactylus/rhynodge/filters/ComicSiteFilter.java @@ -19,6 +19,8 @@ package net.pterodactylus.rhynodge.filters; import static com.google.common.base.Preconditions.*; +import java.net.URI; +import java.net.URISyntaxException; import java.util.List; import net.pterodactylus.rhynodge.Filter; @@ -58,9 +60,14 @@ public abstract class ComicSiteFilter implements Filter { int imageCounter = 0; for (String imageUrl : imageUrls) { String imageComment = (imageCounter < imageComments.size()) ? imageComments.get(imageCounter) : ""; - Strip strip = new Strip(imageUrl, imageComment); - imageCounter++; - comic.add(strip); + try { + URI stripUri = new URI(htmlState.uri()).resolve(imageUrl); + Strip strip = new Strip(stripUri.toString(), imageComment); + imageCounter++; + comic.add(strip); + } catch (URISyntaxException use1) { + throw new IllegalStateException(String.format("Could not resolve image URL “%s” against base URL “%s”.", imageUrl, htmlState.uri()), use1); + } } comicState.add(comic); } -- 2.7.4