Adding support to MEGA browser extension (#262)

Now you can copy an URL from Firefox and Chrome MEGA extension and the program will transform it to a ordinary MEGA URL
This commit is contained in:
Luis Alfredo Figueroa Bracamontes 2020-10-31 10:06:48 -06:00 committed by GitHub
parent 0f5a351979
commit a654ada7da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -785,6 +785,9 @@ public class MiscTools {
String res = "";
if (data != null) {
if (data.startsWith("moz-extension") || data.startsWith("chrome-extension"))
data = extensionURL2NormalLink(data);
try {
@ -1402,6 +1405,15 @@ public class MiscTools {
return replace1.replaceAll("https://mega\\.nz/file/([^#]+)#(.+)", "https://mega.nz/#!$1!$2");
}
/* This method changes the MEGA extension URL to a ordinary MEGA URL,
so copying the extension URL from Firefox or Chrome also works as a normal URL */
public static String extensionURL2NormalLink(String data) {
String toReplace = data.substring(0, data.indexOf('#') + 1);
return data.replace(toReplace, "https://mega.nz");
}
private MiscTools() {
}