Use url_view for telemetry uris

This change refactor telemetry code to use bmcweb utility function for
uri construction, which is safe and preferred way, instead of string
operations.

Testing done:
- Some basic GET operations done on Telemetry, no regression.

Signed-off-by: Szymon Dompke <szymon.dompke@intel.com>
Change-Id: I6de5d79a078944d398357f27dc0c201c130c4302
diff --git a/redfish-core/lib/trigger.hpp b/redfish-core/lib/trigger.hpp
index cdd5781..da6a5db 100644
--- a/redfish-core/lib/trigger.hpp
+++ b/redfish-core/lib/trigger.hpp
@@ -143,9 +143,11 @@
     nlohmann::json reports = nlohmann::json::array();
     for (const std::string& name : reportNames)
     {
-        reports.push_back({
-            {"@odata.id", metricReportDefinitionUri + std::string("/") + name},
-        });
+        reports.push_back(
+            {{"@odata.id",
+              crow::utility::urlFromPieces("redfish", "v1", "TelemetryService",
+                                           "MetricReportDefinitions", name)
+                  .string()}});
     }
 
     return reports;
@@ -214,7 +216,9 @@
     }
 
     json["@odata.type"] = "#Triggers.v1_2_0.Triggers";
-    json["@odata.id"] = triggerUri + std::string("/") + id;
+    json["@odata.id"] = crow::utility::urlFromPieces(
+                            "redfish", "v1", "TelemetryService", "Triggers", id)
+                            .string();
     json["Id"] = id;
     json["Name"] = *name;
 
@@ -282,8 +286,7 @@
                const std::shared_ptr<bmcweb::AsyncResp>& asyncResp) {
                 asyncResp->res.jsonValue["@odata.type"] =
                     "#TriggersCollection.TriggersCollection";
-                asyncResp->res.jsonValue["@odata.id"] =
-                    "/redfish/v1/TelemetryService/Triggers";
+                asyncResp->res.jsonValue["@odata.id"] = telemetry::triggerUri;
                 asyncResp->res.jsonValue["Name"] = "Triggers Collection";
                 const std::vector<const char*> interfaces{
                     telemetry::triggerInterface};