3781: One less Regexp.
[arvados.git] / apps / workbench / app / assets / javascripts / arvados_client.js
index eaffaf7b58792cc7b7e845fd4874c2efe1b2818f..b3f18ad65b21d0cd4223d088b79a68c888aa2c37 100644 (file)
@@ -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;