diff --git a/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java b/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java index 279d82d1..cb3e7595 100644 --- a/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java +++ b/src/main/java/com/rarchives/ripme/ripper/rippers/DeviantartRipper.java @@ -64,8 +64,10 @@ public class DeviantartRipper extends AbstractJSONRipper { public URL sanitizeURL(URL url) throws MalformedURLException { String u = url.toExternalForm(); - if (!u.endsWith("/gallery/")) { - if (!u.endsWith("/gallery")) { + if (!u.endsWith("/gallery/") && !u.endsWith("/gallery")) { + if (!u.endsWith("/")) { + u += "/gallery/"; + } else { u += "gallery/"; } } diff --git a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DeviantartRipperTest.java b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DeviantartRipperTest.java index 52b6bc59..6a1a054b 100644 --- a/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DeviantartRipperTest.java +++ b/src/test/java/com/rarchives/ripme/tst/ripper/rippers/DeviantartRipperTest.java @@ -2,6 +2,8 @@ package com.rarchives.ripme.tst.ripper.rippers; import java.io.IOException; import java.net.URL; +import java.util.ArrayList; +import java.util.List; import com.rarchives.ripme.ripper.rippers.DeviantartRipper; import com.rarchives.ripme.utils.Http; @@ -32,4 +34,16 @@ public class DeviantartRipperTest extends RippersTest { assertEquals("airgee", ripper.getUsername(doc)); assertEquals("714589", ripper.getGalleryID(doc)); } + + public void testSanitizeURL() throws IOException { + List urls = new ArrayList(); + urls.add(new URL("https://www.deviantart.com/airgee/")); + urls.add(new URL("https://www.deviantart.com/airgee")); + urls.add(new URL("https://www.deviantart.com/airgee/gallery/")); + + for (URL url : urls) { + DeviantartRipper ripper = new DeviantartRipper(url); + assertEquals("https://www.deviantart.com/airgee/gallery/", ripper.sanitizeURL(url).toExternalForm()); + } + } }