Page Speed Optimization Libraries
1.3.25.1
|
Helper class for converting a URL into a filename. More...
#include "url_to_filename_encoder.h"
Static Public Member Functions | |
static GoogleString | Encode (const GoogleString &url, GoogleString base_path, bool legacy_escape) |
static void | EncodeSegment (const GoogleString &filename_prefix, const GoogleString &escaped_ending, char dir_separator, GoogleString *encoded_filename) |
static bool | Decode (const GoogleString &encoded_filename, char dir_separator, GoogleString *decoded_url) |
static GoogleString | Unescape (const GoogleString &escaped_url) |
Static Public Attributes | |
static const char | kEscapeChar |
static const char | kTruncationChar |
static const size_t | kMaximumSubdirectoryLength |
Friends | |
class | UrlToFilenameEncoderTest |
Helper class for converting a URL into a filename.
static bool net_instaweb::UrlToFilenameEncoder::Decode | ( | const GoogleString & | encoded_filename, |
char | dir_separator, | ||
GoogleString * | decoded_url | ||
) | [static] |
Decodes a filename that was encoded with EncodeSegment, yielding back the original URL.
static GoogleString net_instaweb::UrlToFilenameEncoder::Encode | ( | const GoogleString & | url, |
GoogleString | base_path, | ||
bool | legacy_escape | ||
) | [inline, static] |
Given a |url| and a |base_path|, returns a filename which represents this |url|. |url| may include URL escaping such as %21 for ! |legacy_escape| indicates that this function should use the old-style of encoding.
Strip the leading '/'.
Replace '/' with '\'.
Strip double back-slashes ("\\\\").
Save path as filesystem-safe characters.
Last step - convert to native slashes.
static void net_instaweb::UrlToFilenameEncoder::EncodeSegment | ( | const GoogleString & | filename_prefix, |
const GoogleString & | escaped_ending, | ||
char | dir_separator, | ||
GoogleString * | encoded_filename | ||
) | [static] |
Rewrite HTML in a form that the SPDY in-memory server can read. |filename_prefix| is prepended without escaping. |escaped_ending| is the URL to be encoded into a filename. It may have URL escaped characters (like %21 for !). |dir_separator| is "/" on Unix, "\" on Windows. |encoded_filename| is the resultant filename.
static GoogleString net_instaweb::UrlToFilenameEncoder::Unescape | ( | const GoogleString & | escaped_url | ) | [static] |
Unescape a url, converting all XX to the the actual char 0xXX. For example, this will convert "foo%21bar" to "foo!bar".
This will work with strings that have embedded NULLs.