From ccba2e008f5f10691873e43b7506b63debda7f58 Mon Sep 17 00:00:00 2001 From: ApurvR20 Date: Fri, 21 Aug 2026 11:38:11 +0530 Subject: [PATCH] tdf#171853 Replace lastIndexOf by endsWith in pkgcontent.cxx Change-Id: I9b1e840af20b80a946b7a79f141e505cc7aa4838 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/209441 Tested-by: Jenkins Reviewed-by: Ilmari Lauhakangas --- ucb/source/ucp/package/pkgcontent.cxx | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ucb/source/ucp/package/pkgcontent.cxx b/ucb/source/ucp/package/pkgcontent.cxx index 0a6d9aca1c79..43bd800b94c5 100644 --- a/ucb/source/ucp/package/pkgcontent.cxx +++ b/ucb/source/ucp/package/pkgcontent.cxx @@ -160,8 +160,7 @@ rtl::Reference Content::create( { // resource exists - sal_Int32 nLastSlash = aURL.lastIndexOf( '/' ); - if ( ( nLastSlash + 1 ) == aURL.getLength() ) + if ( aURL.endsWith('/') ) { // Client explicitly requested a folder! if ( !aProps.bIsFolder ) @@ -179,8 +178,7 @@ rtl::Reference Content::create( bool bFolder = false; // Guess type according to URI. - sal_Int32 nLastSlash = aURL.lastIndexOf( '/' ); - if ( ( nLastSlash + 1 ) == aURL.getLength() ) + if ( aURL.endsWith('/') ) bFolder = true; uno::Reference< ucb::XContentIdentifier > xId @@ -1504,7 +1502,7 @@ void Content::insert( } OUString aNewURL = m_aUri.getParentUri(); - if (1 + aNewURL.lastIndexOf('/') != aNewURL.getLength()) + if (!aNewURL.endsWith('/')) aNewURL += "/"; aNewURL += ::ucb_impl::urihelper::encodeSegment( m_aProps.aTitle ); PackageUri aNewUri( aNewURL ); @@ -2015,7 +2013,7 @@ void Content::queryChildren( ContentRefList& rChildren ) OUString aURL = m_xIdentifier->getContentIdentifier(); - OSL_ENSURE( aURL.lastIndexOf( '/' ) != ( aURL.getLength() - 1 ), + OSL_ENSURE( !aURL.endsWith('/'), "Content::queryChildren - Invalid URL!" ); aURL += "/";