Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: net/data/proxy_resolver_v8_unittest/passthrough.js

Issue 992733002: Remove //net (except for Android test stuff) and sdch (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Return a single-proxy result, which encodes ALL the arguments that were
2 // passed to FindProxyForURL().
3
4 function FindProxyForURL(url, host) {
5 if (arguments.length != 2) {
6 throw "Wrong number of arguments passed to FindProxyForURL!";
7 return "FAIL";
8 }
9
10 return "PROXY " + makePseudoHost(url + "." + host);
11 }
12
13 // Form a string that kind-of resembles a host. We will replace any
14 // non-alphanumeric character with a dot, then fix up the oddly placed dots.
15 function makePseudoHost(str) {
16 var result = "";
17
18 for (var i = 0; i < str.length; ++i) {
19 var c = str.charAt(i);
20 if (!isValidPseudoHostChar(c)) {
21 c = '.'; // Replace unsupported characters with a dot.
22 }
23
24 // Take care not to place multiple adjacent dots,
25 // a dot at the beginning, or a dot at the end.
26 if (c == '.' &&
27 (result.length == 0 ||
28 i == str.length - 1 ||
29 result.charAt(result.length - 1) == '.')) {
30 continue;
31 }
32 result += c;
33 }
34 return result;
35 }
36
37 function isValidPseudoHostChar(c) {
38 if (c >= '0' && c <= '9')
39 return true;
40 if (c >= 'a' && c <= 'z')
41 return true;
42 if (c >= 'A' && c <= 'Z')
43 return true;
44 return false;
45 }
OLDNEW
« no previous file with comments | « net/data/proxy_resolver_v8_unittest/pac_library_unittest.js ('k') | net/data/proxy_resolver_v8_unittest/resolve_host.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698