Uploaded image for project: 'Qbs ("Cubes")'
  1. Qbs ("Cubes")
  2. QBS-1099

QBS JavaScript lastIndexOf always returns -1

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P2: Important P2: Important
    • None
    • 1.7.1
    • General, Platforms: Windows
    • None
    • Windows 10 x86
      Qt Creator 4.2.1

      Here is a test qbs project.
      For each case lastIndexOf always returns -1.

      import qbs
       
      Product {
          type: ["dummy"]
          Rule {
              multiplex: true
              alwaysRun: true
              Artifact {
                  filePath: "dummy.txt"
                  fileTags: ["dummy"]
              }
              prepare: {
                  var cmd = new JavaScriptCommand();
                  cmd.silent = false;
                  cmd.description = 'Testing JavaScript';
                  cmd.sourceCode = function() {
                      var str1 = "C:/dir1/dir2/dir3";
                      var index1 = str1.indexOf('/');
                      var index2 = str1.lastIndexOf("/");
                      console.error('indexes: ' + index1 + ' ' + index2);
       
                      var str2 = "bbbbaaaaa";
                      console.error('indexes: ' + str2.indexOf("a") + ' ' + str2.lastIndexOf("a"));
       
                      var str3 = "112211221";
                      console.error('indexes: ' + str3.indexOf("2") + ' ' + str3.lastIndexOf("2"));
                  };
                  return [cmd];
              }
          }
      }
      

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            jbornema Joerg Bornemann
            vmatyushin Vyacheslav Matyushin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes