Update CollectionMembers to use UrlFromPieces

Refactor getCollectionMembers to make sure all Url created with dbus
paths are generated via UrlFromPieces helper function. This allow us to
manage all URL generated from dbus in one place and allow us to make
future changes to affect all resources.

We can make changes to all resources easier if they are all managed by
one function.

Tested:
Redfish Validator Passed. All Collections working as expected and match
previous implmentation.

Change-Id: I5d3b2b32f047ce4f20a2287a36a3e099efd6eace
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/redfish-core/include/utils/collection.hpp b/redfish-core/include/utils/collection.hpp
index 7a845d1..97f622d 100644
--- a/redfish-core/include/utils/collection.hpp
+++ b/redfish-core/include/utils/collection.hpp
@@ -24,11 +24,12 @@
  */
 inline void
     getCollectionMembers(std::shared_ptr<bmcweb::AsyncResp> aResp,
-                         const std::string& collectionPath,
+                         const boost::urls::url& collectionPath,
                          const std::vector<const char*>& interfaces,
                          const char* subtree = "/xyz/openbmc_project/inventory")
 {
-    BMCWEB_LOG_DEBUG << "Get collection members for: " << collectionPath;
+    BMCWEB_LOG_DEBUG << "Get collection members for: "
+                     << collectionPath.string();
     crow::connections::systemBus->async_method_call(
         [collectionPath, aResp{std::move(aResp)}](
             const boost::system::error_code ec,
@@ -65,11 +66,10 @@
         members = nlohmann::json::array();
         for (const std::string& leaf : pathNames)
         {
-            std::string newPath = collectionPath;
-            newPath += '/';
-            newPath += leaf;
+            boost::urls::url url = collectionPath;
+            crow::utility::appendUrlPieces(url, leaf);
             nlohmann::json::object_t member;
-            member["@odata.id"] = std::move(newPath);
+            member["@odata.id"] = std::move(url);
             members.push_back(std::move(member));
         }
         aResp->res.jsonValue["Members@odata.count"] = members.size();