Ticket #209: addHashSign.patch

File addHashSign.patch, 1.0 kB (added by Mardak, 2 years ago)

add hash for ref and don't match #!!abc123

  • trunk/chrome/content/common/overlayFunctions.js

    old new  
    736736 
    737737/** 
    738738 * Get a link-fingerprint hash from an url (or just the hash component) 
    739739 * @param url. Either String or nsIURI 
    740740 * @return Valid hash string or null 
    741741 */ 
    742742function DTA_getLinkPrintHash(url) { 
    743743  if (url instanceof Components.interfaces.nsIURL) { 
    744     url = url.ref; 
     744    url = '#' + url.ref; 
    745745  } 
    746746  else if (url instanceof Components.interfaces.nsIURI) { 
    747747    url = url.spec; 
    748748  } 
    749749  else if (typeof(url) != 'string' && !(url instanceof String)) { 
    750750    return null; 
    751751  } 
    752752   
    753   var lp = url.match(/#!(md5|sha(?:1|256|384|512)|)!([\da-f]+)$/i); 
     753  var lp = url.match(/#!(md5|sha(?:1|256|384|512))!([\da-f]+)$/i); 
    754754  if (lp) { 
    755755    try { 
    756756      return new DTA_Hash(lp[2], lp[1]); 
    757757    } 
    758758    catch (ex) { 
    759759      // pass down 
    760760    } 
    761761  }