mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-12-30 22:55:49 +01:00
feat(reddit): add sanitize-sharing-links
patch (#407)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
This commit is contained in:
parent
d9a75ea46a
commit
191cc711de
@ -0,0 +1,25 @@
|
||||
package app.revanced.reddit.patches;
|
||||
|
||||
import app.revanced.integrations.utils.LogHelper;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
|
||||
public final class SanitizeUrlQueryPatch {
|
||||
/**
|
||||
* Strip query parameters from a given URL string.
|
||||
*
|
||||
* @param urlString URL string to strip query parameters from.
|
||||
* @return URL string without query parameters if possible, otherwise the original string.
|
||||
*/
|
||||
public static String stripQueryParameters(final String urlString) {
|
||||
try {
|
||||
final var url = new URL(urlString);
|
||||
|
||||
return url.getProtocol() + "://" + url.getHost() + url.getPath();
|
||||
} catch (MalformedURLException e) {
|
||||
LogHelper.printException(() -> "Can not parse URL", e);
|
||||
return urlString;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user