MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / sanitizePath

Method sanitizePath

src/plugins/sftp/src/com/foxdebug/sftp/Sftp.java:705–723  ·  view source on GitHub ↗
(String path)

Source from the content-addressed store, hash-verified

703 }
704
705 private String sanitizePath(String path) {
706 try {
707 String decodedPath = URLDecoder.decode(
708 path,
709 StandardCharsets.UTF_8.toString()
710 );
711 String encodedPath = URLEncoder.encode(
712 decodedPath,
713 StandardCharsets.UTF_8.toString()
714 )
715 .replace("+", "%20") // Replace + with %20 for spaces
716 .replace("%2F", "/") // Preserve forward slashes
717 .replace("%5C", "\\"); // Preserve backslashes if needed
718
719 return encodedPath;
720 } catch (UnsupportedEncodingException e) {
721 return path; // Return original if encoding fails
722 }
723 }
724
725 public void close(JSONArray args, CallbackContext callback) {
726 cordova

Callers 1

runMethod · 0.95

Calls 3

decodeMethod · 0.80
toStringMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected