You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by dp...@apache.org on 2024/11/01 04:18:05 UTC
(cordova-js) branch master updated: fix: Fix potential edge case in cordova.js detection (#284)
This is an automated email from the ASF dual-hosted git repository.
dpogue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-js.git
The following commit(s) were added to refs/heads/master by this push:
new 08a210de fix: Fix potential edge case in cordova.js detection (#284)
08a210de is described below
commit 08a210de07d14ccbdf2270a42cc5060d869e5f9b
Author: Darryl Pogue <da...@dpogue.ca>
AuthorDate: Thu Oct 31 21:18:00 2024 -0700
fix: Fix potential edge case in cordova.js detection (#284)
Because `indexOf` returns -1 in the case of no match, and a subtraction
of string lengths can also potentially result in -1, we want to make
sure the index is NOT -1 before we try to substring with it.
---
src/common/pluginloader.js | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/common/pluginloader.js b/src/common/pluginloader.js
index 3cc55a6c..d65efed9 100644
--- a/src/common/pluginloader.js
+++ b/src/common/pluginloader.js
@@ -101,7 +101,8 @@ function findCordovaPath () {
var term = '/cordova.js';
for (var n = scripts.length - 1; n > -1; n--) {
var src = scripts[n].src.replace(/\?.*$/, ''); // Strip any query param (CB-6007).
- if (src.indexOf(term) === (src.length - term.length)) {
+ var index = src.indexOf(term);
+ if (index !== -1 && index === (src.length - term.length)) {
path = src.substring(0, src.length - term.length) + '/';
break;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org