Merge branch '4523-owner_uuid-index' refs #4523
[arvados.git] / apps / workbench / app / assets / javascripts / arvados_client.js
index eaffaf7b58792cc7b7e845fd4874c2efe1b2818f..63f1de1538bb67dda2cf1816e72cca1b5761e4ea 100644 (file)
@@ -22,7 +22,7 @@ function ArvadosClient(arvadosApiToken, arvadosDiscoveryUri) {
             var meth = discoveryDoc.resources[controller].methods[action];
             var data = $.extend({}, params, {_method: meth.httpMethod});
             $.each(data, function(k, v) {
-                if (typeof(v) == 'object') {
+                if (typeof(v) === 'object') {
                     data[k] = JSON.stringify(v);
                 }
             });
@@ -61,8 +61,7 @@ function ArvadosClient(arvadosApiToken, arvadosDiscoveryUri) {
         var nameStub = origName;
         var suffixInt = null;
         var ok = false;
-        var lineMatch, linesRe = /[^\n]+/g;
-        var streamNameMatch, streamNameRe = /^\S+/;
+        var lineMatch, linesRe = /(\S+).*/gm;
         var fileTokenMatch, fileTokensRe = / \d+:\d+:(\S+)/g;
         while (!ok) {
             ok = true;
@@ -72,10 +71,11 @@ function ArvadosClient(arvadosApiToken, arvadosDiscoveryUri) {
                 replace(/ /g, '\\040');
             while (ok && null !==
                    (lineMatch = linesRe.exec(manifest))) {
-                streamNameMatch = streamNameRe.exec(lineMatch[0]);
+                // lineMatch is [theEntireLine, streamName]
                 while (ok && null !==
                        (fileTokenMatch = fileTokensRe.exec(lineMatch[0]))) {
-                    if (streamNameMatch[0] + '/' + fileTokenMatch[1]
+                    // fileTokenMatch is [theEntireToken, fileName]
+                    if (lineMatch[1] + '/' + fileTokenMatch[1]
                         ===
                         newStreamName + '/' + newName) {
                         ok = false;