foxygit / Torlinkc Log in
commits tags

/include/torlinkc/util/url_encode.hpp · 482 B

raw
#pragma once

#include <string>

namespace torlinkc {

// Matches JS's encodeURIComponent exactly (same unreserved-character set:
// A-Z a-z 0-9 - _ . ! ~ * ' ( )), so URLs built here byte-match the
// TypeScript original's. Shared by every scraper and by magnet building.
std::string encodeURIComponent(const std::string& s);

// Decodes %XX escapes and '+' as space, matching URLSearchParams::get().
std::string decodeURIComponent(const std::string& s);

}  // namespace torlinkc