|
|
@ -38,6 +38,9 @@ public class IndexController { |
|
|
|
@ResponseBody |
|
|
|
@ResponseBody |
|
|
|
public R generateShortURL(@RequestParam String longURL) { |
|
|
|
public R generateShortURL(@RequestParam String longURL) { |
|
|
|
if (UrlUtils.checkURL(longURL)) { |
|
|
|
if (UrlUtils.checkURL(longURL)) { |
|
|
|
|
|
|
|
if (!longURL.startsWith("http")) { |
|
|
|
|
|
|
|
longURL = "http://" + longURL; |
|
|
|
|
|
|
|
} |
|
|
|
String shortURL = urlService.saveUrlMap(HashUtils.hashToBase62(longURL), longURL, longURL); |
|
|
|
String shortURL = urlService.saveUrlMap(HashUtils.hashToBase62(longURL), longURL, longURL); |
|
|
|
return R.ok("请求成功", host + shortURL); |
|
|
|
return R.ok("请求成功", host + shortURL); |
|
|
|
} |
|
|
|
} |
|
|
|