My Cordova application has an interesting behavior discrepancy when using the Cordova serve option. I have a text input field where users can enter a link, and if they forget to include 'http://' or 'https://' at the beginning of the URL, it automatically adds it once the string length reaches more than 8 characters.
When I use 'cordova serve android' to run the app directly in the browser, the functionality works as expected. For example, typing in 'www.nba.' automatically changes to 'http://www.nba.'.
However, when I run 'cordova run android' and use the app on a mobile device, the same code behaves differently. For instance, when I input 'www.nba.', the string changes to 'http://w|ww.nba.' with the cursor positioned between the first and second 'w' in 'www'.
I have tested this with various keyboards, including the stock ROM keyboard, but the issue persists consistently. Here is the simple code snippet responsible for this functionality:
var pattern = new RegExp("^(http|https)://");
if (pattern.test($scope.post.link) === false) {
$scope.post.link = 'http://' + $scope.post.link;
}
Can anyone provide insight into why this behavior occurs on the Cordova build on the phone but not during actual Cordova serve?