title: Determine if one folder is subfolder of another javascript?
body: <p>I have this function for checking if a root folder has already been added to the list of folders</p>
  
  <pre><code>function folderRootFolderExists(newFolder) {
      for (var folder in $rootScope.syncObj.currentFolders){
          if ($rootScope.syncObj.currentFolders.hasOwnProperty(folder)) {
              if (newFolder.indexOf($rootScope.syncObj.currentFolders[folder].folderPath) &gt; -1){
                  return true;
              }
          }
      }
  
      return false;
  }
  </code></pre>
  
  <p>The problem is that two paths like this return true:</p>
  
  <p>/user/me/Folder</p>
  
  <p>/user/me/Folder (1)</p>
  
  <p>Is there a known js library for dealing with file path strings or a more robust solution for determining these sort of things?</p>