From 48ac359e2015beff4c18f50f1f32ee2d7ffa108d Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Wed, 30 Jan 2019 10:35:08 +0100
Subject: [PATCH] chore: refactor res purl

---
 lib/util/purl.js | 50 ++++++++++++++++++++++++------------------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/lib/util/purl.js b/lib/util/purl.js
index bc89cc3327..f3f3805f90 100644
--- a/lib/util/purl.js
+++ b/lib/util/purl.js
@@ -10,50 +10,50 @@ function parse(input) {
   if (!input.startsWith(scheme)) {
     return null;
   }
-  const res = {};
+  const purl = {};
   let remaining = input.substring(scheme.length);
   let parts = remaining.split('#');
   if (parts.length > 1) {
-    [remaining, res.subpath] = parts;
+    [remaining, purl.subpath] = parts;
   }
   parts = remaining.split('?');
   if (parts.length > 1) {
-    [remaining, res.qualifiers] = parts;
+    [remaining, purl.qualifiers] = parts;
   }
   parts = remaining.split('@');
   if (parts.length > 1) {
-    [remaining, res.version] = parts;
+    [remaining, purl.version] = parts;
   }
   parts = remaining.split('/');
-  [res.datasource, ...remaining] = parts;
+  [purl.datasource, ...remaining] = parts;
   if (remaining.length === 1) {
-    [res.name] = remaining;
-    res.lookupName = res.name;
+    [purl.name] = remaining;
+    purl.lookupName = purl.name;
   } else {
-    res.name = remaining.pop();
-    res.namespace = remaining.join('/').replace('%40', '@');
-    res.lookupName = res.namespace + '/' + res.name;
+    purl.name = remaining.pop();
+    purl.namespace = remaining.join('/').replace('%40', '@');
+    purl.lookupName = purl.namespace + '/' + purl.name;
   }
-  if (res.qualifiers) {
-    const allQualifiers = res.qualifiers.split('&');
-    res.qualifiers = {};
+  if (purl.qualifiers) {
+    const allQualifiers = purl.qualifiers.split('&');
+    purl.qualifiers = {};
     allQualifiers.forEach(qualifier => {
       const [key, val] = qualifier.split('=');
-      res.qualifiers[key] = val;
+      purl.qualifiers[key] = val;
     });
-    if (res.qualifiers.repository_url) {
-      res.registryUrls = res.qualifiers.repository_url.split(',');
-      delete res.qualifiers.repository_url;
+    if (purl.qualifiers.repository_url) {
+      purl.registryUrls = purl.qualifiers.repository_url.split(',');
+      delete purl.qualifiers.repository_url;
     }
   } else {
-    res.qualifiers = {};
+    purl.qualifiers = {};
   }
-  if (res.subpath) {
-    res.lookupType = res.subpath;
-    delete res.subpath;
+  if (purl.subpath) {
+    purl.lookupType = purl.subpath;
+    delete purl.subpath;
   }
-  delete res.namespace;
-  delete res.name;
-  delete res.version; // we don't use it
-  return res;
+  delete purl.namespace;
+  delete purl.name;
+  delete purl.version; // we don't use it
+  return purl;
 }
-- 
GitLab