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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/components/Linkifier.js

Issue 1805763002: [DevTools] Do not linkify relative urls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed review comments Created 4 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
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 * @param {string=} linkText 505 * @param {string=} linkText
506 * @param {string=} classes 506 * @param {string=} classes
507 * @param {boolean=} isExternal 507 * @param {boolean=} isExternal
508 * @param {string=} tooltipText 508 * @param {string=} tooltipText
509 * @return {!Element} 509 * @return {!Element}
510 */ 510 */
511 WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal, too ltipText) 511 WebInspector.linkifyURLAsNode = function(url, linkText, classes, isExternal, too ltipText)
512 { 512 {
513 if (!linkText) 513 if (!linkText)
514 linkText = url; 514 linkText = url;
515 classes = (classes ? classes + " " : "");
516 classes += isExternal ? "webkit-html-external-link" : "webkit-html-resource- link";
517 515
518 var a = createElement("a"); 516 var a = createElementWithClass("a", classes);
519 var href = sanitizeHref(url); 517 var href = url;
520 if (href !== null) 518 if (url.trim().toLowerCase().startsWith("javascript:"))
519 href = null;
520 if (isExternal && WebInspector.ParsedURL.isRelativeURL(url))
521 href = null;
522 if (href !== null) {
521 a.href = href; 523 a.href = href;
522 a.className = classes; 524 a.classList.add(isExternal ? "webkit-html-external-link" : "webkit-html- resource-link");
525 }
523 if (!tooltipText && linkText !== url) 526 if (!tooltipText && linkText !== url)
524 a.title = url; 527 a.title = url;
525 else if (tooltipText) 528 else if (tooltipText)
526 a.title = tooltipText; 529 a.title = tooltipText;
527 a.textContent = linkText.trimMiddle(WebInspector.Linkifier.MaxLengthForDispl ayedURLs); 530 a.textContent = linkText.trimMiddle(WebInspector.Linkifier.MaxLengthForDispl ayedURLs);
528 if (isExternal) 531 if (isExternal)
529 a.setAttribute("target", "_blank"); 532 a.setAttribute("target", "_blank");
530 533
531 return a; 534 return a;
532 } 535 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
564 /** 567 /**
565 * @param {!WebInspector.NetworkRequest} request 568 * @param {!WebInspector.NetworkRequest} request
566 * @return {!Element} 569 * @return {!Element}
567 */ 570 */
568 WebInspector.linkifyRequestAsNode = function(request) 571 WebInspector.linkifyRequestAsNode = function(request)
569 { 572 {
570 var anchor = WebInspector.linkifyURLAsNode(request.url); 573 var anchor = WebInspector.linkifyURLAsNode(request.url);
571 anchor.requestId = request.requestId; 574 anchor.requestId = request.requestId;
572 return anchor; 575 return anchor;
573 } 576 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698