Added better url sanitization for DeviantartRipper and some unit tests
This commit is contained in:
parent
0ed2a7ddac
commit
d0960fad75
@ -64,8 +64,10 @@ public class DeviantartRipper extends AbstractJSONRipper {
|
|||||||
public URL sanitizeURL(URL url) throws MalformedURLException {
|
public URL sanitizeURL(URL url) throws MalformedURLException {
|
||||||
String u = url.toExternalForm();
|
String u = url.toExternalForm();
|
||||||
|
|
||||||
if (!u.endsWith("/gallery/")) {
|
if (!u.endsWith("/gallery/") && !u.endsWith("/gallery")) {
|
||||||
if (!u.endsWith("/gallery")) {
|
if (!u.endsWith("/")) {
|
||||||
|
u += "/gallery/";
|
||||||
|
} else {
|
||||||
u += "gallery/";
|
u += "gallery/";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ package com.rarchives.ripme.tst.ripper.rippers;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import com.rarchives.ripme.ripper.rippers.DeviantartRipper;
|
import com.rarchives.ripme.ripper.rippers.DeviantartRipper;
|
||||||
import com.rarchives.ripme.utils.Http;
|
import com.rarchives.ripme.utils.Http;
|
||||||
@ -32,4 +34,16 @@ public class DeviantartRipperTest extends RippersTest {
|
|||||||
assertEquals("airgee", ripper.getUsername(doc));
|
assertEquals("airgee", ripper.getUsername(doc));
|
||||||
assertEquals("714589", ripper.getGalleryID(doc));
|
assertEquals("714589", ripper.getGalleryID(doc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testSanitizeURL() throws IOException {
|
||||||
|
List<URL> urls = new ArrayList<URL>();
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user