MCPcopy Create free account
hub / github.com/crosspoint-reader/crosspoint-reader / getDestinationPath

Method getDestinationPath

src/network/WebDAVHandler.cpp:703–732  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

701}
702
703String WebDAVHandler::getDestinationPath(WebServer& s) const {
704 String dest = s.header("Destination");
705 if (dest.isEmpty()) return "";
706
707 // Extract path from full URL: http://host/path -> /path
708 // Find the third slash (after http://)
709 int schemeEnd = dest.indexOf("://");
710 if (schemeEnd >= 0) {
711 int pathStart = dest.indexOf('/', schemeEnd + 3);
712 if (pathStart >= 0) {
713 dest = dest.substring(pathStart);
714 } else {
715 dest = "/";
716 }
717 }
718
719 String decoded = WebServer::urlDecode(dest);
720 std::string normalized = FsHelpers::normalisePath(decoded.c_str());
721 String result = normalized.c_str();
722
723 if (result.isEmpty()) return "/";
724 if (!result.startsWith("/")) result = "/" + result;
725
726 // Remove trailing slash unless root
727 if (result.length() > 1 && result.endsWith("/")) {
728 result = result.substring(0, result.length() - 1);
729 }
730
731 return result;
732}
733
734void WebDAVHandler::urlEncodePath(const String& path, String& out) const {
735 out = "";

Callers

nothing calls this directly

Calls 2

normalisePathFunction · 0.85
isEmptyMethod · 0.45

Tested by

no test coverage detected