Page Speed Optimization Libraries  1.3.25.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Static Public Member Functions | Static Public Attributes | Friends
net_instaweb::UrlToFilenameEncoder Class Reference

Helper class for converting a URL into a filename. More...

#include "url_to_filename_encoder.h"

List of all members.

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

Detailed Description

Helper class for converting a URL into a filename.


Member Function Documentation

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.

Todo:
TODO(mbelshe): delete the legacy_escape code.

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.

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.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines