// this module helps finding if the current page is using
// the cdn.jsdelivr.net/algoliasearch/latest/$BUILDNAME.min.js version

module.exports = isUsingLatest;

function isUsingLatest(buildName) {
  var toFind = new RegExp('cdn.jsdelivr.net/algoliasearch/latest' +
    buildName.replace('.', '\\.') + // algoliasearch, algoliasearch.angular
    '(?:\\.min)?\\.js$'); // [.min].js

  var scripts = document.getElementsByTagName('script');
  var found = false;
  for (var currentScript = 0, nbScripts = scripts.length;
        currentScript < nbScripts;
        currentScript++) {
    if (scripts[currentScript].src && toFind.test(scripts[currentScript].src)) {
      found = true;
      break;
    }
  }

  return found;
}

@@ -222,16 +222,18 @@
 Exp('cdn
+%5C%5C
 .jsdeliv
@@ -225,32 +225,34 @@
 ('cdn%5C%5C.jsdelivr
+%5C%5C
 .net/algoliasear
@@ -260,16 +260,17 @@
 h/latest
+/
 ' +%0A    

fix regexp