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;
}
