about summary refs log tree commit diff
path: root/MatrixRoomUtils.Core/Extensions/StringExtensions.cs
diff options
context:
space:
mode:
authorTheArcaneBrony <myrainbowdash949@gmail.com>2023-05-01 02:43:32 +0200
committerTheArcaneBrony <myrainbowdash949@gmail.com>2023-05-01 02:43:32 +0200
commitdf9031c47f8e97d8e2df3177093271a458f27267 (patch)
tree4e81dec4048c6e76a928ef69c905560d7c173fdf /MatrixRoomUtils.Core/Extensions/StringExtensions.cs
downloadMatrixUtils-df9031c47f8e97d8e2df3177093271a458f27267.tar.xz
Initial commit
Diffstat (limited to 'MatrixRoomUtils.Core/Extensions/StringExtensions.cs')
-rw-r--r--MatrixRoomUtils.Core/Extensions/StringExtensions.cs17
1 files changed, 17 insertions, 0 deletions
diff --git a/MatrixRoomUtils.Core/Extensions/StringExtensions.cs b/MatrixRoomUtils.Core/Extensions/StringExtensions.cs
new file mode 100644
index 0000000..e02f0b9
--- /dev/null
+++ b/MatrixRoomUtils.Core/Extensions/StringExtensions.cs
@@ -0,0 +1,17 @@
+using MatrixRoomUtils.Authentication;
+
+namespace MatrixRoomUtils.Extensions;
+
+public static class StringExtensions
+{
+    public static async Task<string> GetMediaUrl(this string MxcUrl)
+    {
+        //MxcUrl: mxc://rory.gay/ocRVanZoUTCcifcVNwXgbtTg
+        //target: https://matrix.rory.gay/_matrix/media/v3/download/rory.gay/ocRVanZoUTCcifcVNwXgbtTg
+        
+        var server = MxcUrl.Split('/')[2];
+        var mediaId = MxcUrl.Split('/')[3];
+        return $"{await MatrixAccount.ResolveHomeserverFromWellKnown(server)}/_matrix/media/v3/download/{server}/{mediaId}";
+    }
+    
+}
\ No newline at end of file