Fix all urls and empty shortUrl check

This commit is contained in:
Przemek Dragańczuk 2020-02-14 19:43:45 +01:00
parent 0f41363740
commit a61e820b5e

View File

@ -1,14 +1,10 @@
package tk.draganczuk.url;
import java.io.IOException;
import java.util.List;
import java.util.UUID;
import org.eclipse.jetty.util.log.Log;
import spark.Request;
import spark.Response;
import java.io.IOException;
public class Routes {
private static UrlFile urlFile;
@ -21,15 +17,15 @@ public class Routes {
}
}
public static List<String> getAll(Request req, Response res) throws IOException{
return urlFile.getAll();
public static String getAll(Request req, Response res) throws IOException {
return String.join("\n", urlFile.getAll());
}
public static String addUrl(Request req, Response res) {
String longUrl = req.queryParams("long");
String shortUrl = req.queryParams("short");
if (shortUrl == null) {
if (shortUrl == null || shortUrl.isBlank()) {
shortUrl = Utils.randomString();
}