desktop/source/deployment/misc/dp_misc.cxx |   39 +++++++++++++----------------
 1 file changed, 18 insertions(+), 21 deletions(-)

New commits:
commit 5f2d50bade4d61b6eed9f2848ef23a0fe6c4a290
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Jul 23 11:25:58 2025 +0200
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Wed Jul 23 15:52:36 2025 +0200

    Simplify dp_misc::makeURL a bit
    
    Change-Id: I3b10f3120463f3a13161a4a7d0f97cbd1c589671
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/188210
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/desktop/source/deployment/misc/dp_misc.cxx 
b/desktop/source/deployment/misc/dp_misc.cxx
index b08b40c0f91e..5294c96545f7 100644
--- a/desktop/source/deployment/misc/dp_misc.cxx
+++ b/desktop/source/deployment/misc/dp_misc.cxx
@@ -256,32 +256,29 @@ OUString encodeForRcFile( std::u16string_view str )
 
 OUString makeURL( std::u16string_view baseURL, OUString const & relPath_ )
 {
-    OUStringBuffer buf(128);
-    if (baseURL.size() > 1 && baseURL[ baseURL.size() - 1 ] == '/')
-        buf.append( baseURL.substr(0, baseURL.size() - 1) );
-    else
-        buf.append( baseURL );
+    if (baseURL.ends_with('/'))
+        baseURL.remove_suffix(1);
+
     OUString relPath(relPath_);
     if( relPath.startsWith("/") )
         relPath = relPath.copy( 1 );
-    if (!relPath.isEmpty())
+
+    if (relPath.isEmpty())
+        return OUString(baseURL);
+
+    if (baseURL.starts_with(u"vnd.sun.star.expand:"))
     {
-        buf.append( '/' );
-        if (o3tl::starts_with(baseURL, u"vnd.sun.star.expand:" )) {
-            // encode for macro expansion: relPath is supposed to have no
-            // macros, so encode $, {} \ (bootstrap mimic)
-            relPath = encodeForRcFile(relPath);
-
-            // encode once more for vnd.sun.star.expand schema:
-            // vnd.sun.star.expand:$UNO_...
-            // will expand to file-url
-            relPath = ::rtl::Uri::encode( relPath, rtl_UriCharClassUric,
-                                          rtl_UriEncodeIgnoreEscapes,
-                                          RTL_TEXTENCODING_UTF8 );
-        }
-        buf.append( relPath );
+        // encode for macro expansion: relPath is supposed to have no
+        // macros, so encode $, {} \ (bootstrap mimic)
+        relPath = encodeForRcFile(relPath);
+
+        // encode once more for vnd.sun.star.expand schema:
+        // vnd.sun.star.expand:$UNO_...
+        // will expand to file-url
+        relPath = ::rtl::Uri::encode(relPath, rtl_UriCharClassUric, 
rtl_UriEncodeIgnoreEscapes,
+                                     RTL_TEXTENCODING_UTF8);
     }
-    return buf.makeStringAndClear();
+    return OUString::Concat(baseURL) + "/" + relPath;
 }
 
 OUString makeURLAppendSysPathSegment( std::u16string_view baseURL, OUString 
const & segment )

Reply via email to