aboutsummaryrefslogtreecommitdiff
path: root/node_modules/algoliasearch/src/browser/migration-layer/is-using-latest.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/algoliasearch/src/browser/migration-layer/is-using-latest.js')
-rw-r--r--node_modules/algoliasearch/src/browser/migration-layer/is-using-latest.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/node_modules/algoliasearch/src/browser/migration-layer/is-using-latest.js b/node_modules/algoliasearch/src/browser/migration-layer/is-using-latest.js
new file mode 100644
index 00000000..f8e29d4e
--- /dev/null
+++ b/node_modules/algoliasearch/src/browser/migration-layer/is-using-latest.js
@@ -0,0 +1,23 @@
+'use strict';
+
+// 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;
+}