2
* Copyright 2010 Google Inc.
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* You may obtain a copy of the License at
8
* http://www.apache.org/licenses/LICENSE-2.0
10
* Unless required by applicable law or agreed to in writing, software
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
* See the License for the specific language governing permissions and
14
* limitations under the License.
17
// Author: jmarantz@google.com (Joshua Marantz)
19
#ifndef PAGESPEED_KERNEL_UTIL_URL_ESCAPER_H_
20
#define PAGESPEED_KERNEL_UTIL_URL_ESCAPER_H_
22
#include "pagespeed/kernel/base/string.h"
23
#include "pagespeed/kernel/base/string_util.h"
25
namespace net_instaweb {
28
The intent of this class to encode arbitrary URLs into one 'segment'
29
of a new URL. We escape many special chars like /\?&% to make sure that
30
this encoded version is only one segment.
32
We would like the above URL to be reasonably legible if possible.
33
However it's also nice if it's short.
37
http://www.foo.bar/z1234/b_c.d?e=f&g=h
39
this suggests we should have short encodings for a-zA-Z0-9./?&
41
The transform table is:
43
a-zA-Z0-9_=+-. unchanged
54
everything else ,XX where XX are hex digits using capital letters.
57
namespace UrlEscaper {
59
void EncodeToUrlSegment(const StringPiece& in, GoogleString* url_segment);
60
bool DecodeFromUrlSegment(const StringPiece& url_segment, GoogleString* out);
62
} // namespace UrlEscaper
64
} // namespace net_instaweb
66
#endif // PAGESPEED_KERNEL_UTIL_URL_ESCAPER_H_