Fix regression on expand handling

It was found that as part of
c1d019a6056a2a0ef50e577b3139ab5a8dc49355 Sensor optimization

We missed updating the odata.id for the expand case.  This wasn't really
found because most clients either use expand, or they don't, and
depending on which path you take, both paths are valid.  With that said,
we should be following the spec here, and returning the same result
regardless of whether we're being processed as expand or not.

This patchset is a little rough, and probably should be iterated on.

TODO (at a later date).  Try to get a tool that can detect these
failures.

Tested: Tested by @Carson to resolve the regression.

Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ieed7796895a3c5937fd901d5afa7dd4ea0693099
diff --git a/redfish-core/lib/sensors.hpp b/redfish-core/lib/sensors.hpp
index cf63bd7..ac69f26 100644
--- a/redfish-core/lib/sensors.hpp
+++ b/redfish-core/lib/sensors.hpp
@@ -2544,11 +2544,20 @@
                     }
                     else if (fieldName == "Members")
                     {
+                        std::string sensorTypeEscaped(sensorType);
+                        sensorTypeEscaped.erase(
+                            std::remove(sensorTypeEscaped.begin(),
+                                        sensorTypeEscaped.end(), '_'),
+                            sensorTypeEscaped.end());
+                        std::string sensorId(sensorTypeEscaped);
+                        sensorId += "_";
+                        sensorId += sensorName;
+
                         nlohmann::json::object_t member;
-                        member["@odata.id"] =
-                            "/redfish/v1/Chassis/" +
-                            sensorsAsyncResp->chassisId + "/" +
-                            sensorsAsyncResp->chassisSubNode + "/" + sensorName;
+                        member["@odata.id"] = crow::utility::urlFromPieces(
+                            "redfish", "v1", "Chassis",
+                            sensorsAsyncResp->chassisId,
+                            sensorsAsyncResp->chassisSubNode, sensorId);
                         tempArray.push_back(std::move(member));
                         sensorJson = &(tempArray.back());
                     }
@@ -3007,7 +3016,7 @@
 
 inline void handleSensorGet(App& app, const crow::Request& req,
                             const std::shared_ptr<bmcweb::AsyncResp>& asyncResp,
-                            const std::string& /*chassisId*/,
+                            const std::string& chassisId,
                             const std::string& sensorId)
 {
     if (!redfish::setUpRedfishRoute(app, req, asyncResp))
@@ -3020,6 +3029,8 @@
         messages::resourceNotFound(asyncResp->res, sensorId, "Sensor");
         return;
     }
+    asyncResp->res.jsonValue["@odata.id"] = crow::utility::urlFromPieces(
+        "redfish", "v1", "Chassis", chassisId, "Sensors", sensorId);
     std::string sensorType = sensorId.substr(0, index);
     std::string sensorName = sensorId.substr(index + 1);
     // fan_pwm and fan_tach need special handling