Sending a string with a certain path I want to send a string with the following path, and I want to verify if this is the right way to do that in JavaScript.


Is this the right way to use the return in an if/else, or there is shorter way?  
Is the indexOf using correctly?




https://test.com/plugins/plug/pluginr/poc/fact

function isExt(path) {

  if(path.indexOf("/plug/pluginr/")) {

    return true;

  }
  else {

    return false;

  }

}
Your code seems not to be correct. In case you don't have the substring /plug/pluginr/ it would still return true since indexOf returns an integer containing the position of the first ocurrence. If theres no ocurrence of the substring then it returns -1 which is evaluated to true in JavaScript.

You better use this instead;

function isExt(path){
    return path.indexOf("/plug/pluginr/") &gt; -1;
}