Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: include.postload.js

Issue 10298002: Fixed: Click-to-hide mishandles URLs with leading // (Closed)
Patch Set: Created April 12, 2013, 10:39 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of the Adblock Plus extension, 2 * This file is part of the Adblock Plus extension,
3 * Copyright (C) 2006-2012 Eyeo GmbH 3 * Copyright (C) 2006-2012 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 // Converts relative to absolute URL 333 // Converts relative to absolute URL
334 // e.g.: foo.swf on http://example.com/whatever/bar.html 334 // e.g.: foo.swf on http://example.com/whatever/bar.html
335 // -> http://example.com/whatever/foo.swf 335 // -> http://example.com/whatever/foo.swf
336 function relativeToAbsoluteUrl(url) 336 function relativeToAbsoluteUrl(url)
337 { 337 {
338 // If URL is already absolute, don't mess with it 338 // If URL is already absolute, don't mess with it
339 if (!url || /^[\w\-]+:/i.test(url)) 339 if (!url || /^[\w\-]+:/i.test(url))
340 return url; 340 return url;
341 341
342 // Leading / means absolute path 342 // Leading / means absolute path
343 if(url[0] == '/') 343 // Leading // means network path
344 return document.location.protocol + "//" + document.location.host + url; 344 if (url[0] == '/')
345 {
346 if (url[1] == '/')
347 return document.location.protocol + url;
348 else
349 return document.location.protocol + "//" + document.location.host + url;
350 }
345 351
346 // Remove filename and add relative URL to it 352 // Remove filename and add relative URL to it
347 var base = document.baseURI.match(/.+\//); 353 var base = document.baseURI.match(/.+\//);
348 if(!base) 354 if (!base)
349 return document.baseURI + "/" + url; 355 return document.baseURI + "/" + url;
350 return base[0] + url; 356 return base[0] + url;
351 } 357 }
352 358
353 // This function Copyright (c) 2008 Jeni Tennison, from jquery.uri.js 359 // This function Copyright (c) 2008 Jeni Tennison, from jquery.uri.js
354 // and licensed under the MIT license. See jquery-*.min.js for details. 360 // and licensed under the MIT license. See jquery-*.min.js for details.
355 function removeDotSegments(u) { 361 function removeDotSegments(u) {
356 var r = '', m = []; 362 var r = '', m = [];
357 if (/\./.test(u)) { 363 if (/\./.test(u)) {
358 while (u !== undefined && u !== '') { 364 while (u !== undefined && u !== '') {
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 553
548 clickHide_deactivate(); 554 clickHide_deactivate();
549 } 555 }
550 break; 556 break;
551 default: 557 default:
552 sendResponse({}); 558 sendResponse({});
553 break; 559 break;
554 } 560 }
555 }); 561 });
556 } 562 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld