Components.utils.import("chrome://modules/content/ndn-js.jsm");

function ndnToolbarGetLatest(event){
  if (window._content.document.location.protocol != "ndn:") {
    alert("The address must start with ndn");
    return;
  }

  // Parse the same as in ndnProtocolService newChannel.
  var spec = window._content.document.location.href.trim();
  var preHash = spec.split('#', 1)[0];
  var hash = spec.substr(preHash.length).trim();
  var preSearch = preHash.split('?', 1)[0];
  var search = preHash.substr(preSearch.length).trim();
  // Set nameString to the preSearch without the protocol.
  var nameString = preSearch.trim();
  if (nameString.indexOf(':') >= 0)
    nameString = nameString.substr(nameString.indexOf(':') + 1).trim();

  var name = new Name(nameString);
  var indexOfVersion = getIndexOfVersion(name);
  if (indexOfVersion < 0) {
    alert("The ndn address does not have a version");
    return;
  }

  var nameWithoutVersion = new Name(name.components.slice(0, indexOfVersion));
  var searchWithChildSelector = (search == "" ? "?" : search + "&") + "ndn.ChildSelector=1";
    
  var uri = "ndn:" + nameWithoutVersion.to_uri() + searchWithChildSelector + hash;
  window._content.document.location = uri;
} 

// Return the index of the last component that starts with 0xfd, or -1 if not found.
function getIndexOfVersion(name) {
  for (var i = name.components.length - 1; i >= 0; --i) {
    if (name.components[i].length >= 1 && name.components[i][0] == 0xfd)
      return i;
  }

  return -1;
}
