OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 cookie.addAttribute("httpOnly"); | 405 cookie.addAttribute("httpOnly"); |
406 if (protocolCookie["secure"]) | 406 if (protocolCookie["secure"]) |
407 cookie.addAttribute("secure"); | 407 cookie.addAttribute("secure"); |
408 cookie.setSize(protocolCookie["size"]); | 408 cookie.setSize(protocolCookie["size"]); |
409 return cookie; | 409 return cookie; |
410 } | 410 } |
411 | 411 |
412 /** | 412 /** |
413 * @param {!WebInspector.Cookie} cookie | 413 * @param {!WebInspector.Cookie} cookie |
414 * @param {string} resourceURL | 414 * @param {string} resourceURL |
| 415 * @return {boolean} |
415 */ | 416 */ |
416 WebInspector.Cookies.cookieMatchesResourceURL = function(cookie, resourceURL) | 417 WebInspector.Cookies.cookieMatchesResourceURL = function(cookie, resourceURL) |
417 { | 418 { |
418 var url = resourceURL.asParsedURL(); | 419 var url = resourceURL.asParsedURL(); |
419 if (!url || !WebInspector.Cookies.cookieDomainMatchesResourceDomain(cookie.d
omain(), url.host)) | 420 if (!url || !WebInspector.Cookies.cookieDomainMatchesResourceDomain(cookie.d
omain(), url.host)) |
420 return false; | 421 return false; |
421 return (url.path.startsWith(cookie.path()) | 422 return (url.path.startsWith(cookie.path()) |
422 && (!cookie.port() || url.port == cookie.port()) | 423 && (!cookie.port() || url.port == cookie.port()) |
423 && (!cookie.secure() || url.scheme === "https")); | 424 && (!cookie.secure() || url.scheme === "https")); |
424 } | 425 } |
425 | 426 |
426 /** | 427 /** |
427 * @param {string} cookieDomain | 428 * @param {string} cookieDomain |
428 * @param {string} resourceDomain | 429 * @param {string} resourceDomain |
| 430 * @return {boolean} |
429 */ | 431 */ |
430 WebInspector.Cookies.cookieDomainMatchesResourceDomain = function(cookieDomain,
resourceDomain) | 432 WebInspector.Cookies.cookieDomainMatchesResourceDomain = function(cookieDomain,
resourceDomain) |
431 { | 433 { |
432 if (cookieDomain.charAt(0) !== '.') | 434 if (cookieDomain.charAt(0) !== '.') |
433 return resourceDomain === cookieDomain; | 435 return resourceDomain === cookieDomain; |
434 return !!resourceDomain.match(new RegExp("^([^\\.]+\\.)*" + cookieDomain.sub
string(1).escapeForRegExp() + "$", "i")); | 436 return !!resourceDomain.match(new RegExp("^([^\\.]+\\.)*" + cookieDomain.sub
string(1).escapeForRegExp() + "$", "i")); |
435 } | 437 } |
OLD | NEW |