Uploaded image for project: 'Jira Service Management Data Center'
  1. Jira Service Management Data Center
  2. JSDSERVER-12026

Calling String.prototype.startsWith with position params does not work with installed Assets (Insight)

    XMLWordPrintable

Details

    Description

      Issue Summary

      This is reproducible on Data Center: yes

      Steps to Reproduce

      1. Use any Jira / JSM instance that has Assets (Insight) enabled
      2. Open developer console.log and type "test".startsWith("est", 1)

      Expected Results

      It should return true

      Actual Results

      It returns false because Assets (Insight) code base is overriding the startsWith implementation with only one param

      String.prototype.startsWith = function(str) {
       return this.indexOf(str) == 0;
      }; 

      Workaround

      If you are developing a plugin for an instance that has Assets (Insight) enabled and you want to use the string startsWith prototype with two params, you can

      • Define separate startsWith the method to use rather than use the string prototype one.
      • Or redefine the startsWith prototype with a proper polyfill that supports two params. This one will also be compatible with 1 param.

       

      String.prototype.startsWith = function(searchString, position) {
        position = position || 0;
        return this.indexOf(searchString, position) === position;
      }; 

       

      Attachments

        Activity

          People

            Unassigned Unassigned
            26dfe8128d58 Anh Nguyen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Backbone Issue Sync