From c61a30ac41f757410739b16a87a80d2afe0527c6 Mon Sep 17 00:00:00 2001 From: zkx Date: Fri, 21 Apr 2023 16:33:04 +0800 Subject: [PATCH] update Uri For MediaLibrary. Signed-off-by: zkx --- .../js/file_share/grant_uri_permission.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/interfaces/kits/js/file_share/grant_uri_permission.cpp b/interfaces/kits/js/file_share/grant_uri_permission.cpp index 76529f26a..a48614cfc 100644 --- a/interfaces/kits/js/file_share/grant_uri_permission.cpp +++ b/interfaces/kits/js/file_share/grant_uri_permission.cpp @@ -47,8 +47,28 @@ namespace ModuleFileShare { return Security::AccessToken::TokenIdKit::IsSystemAppByFullTokenID(fullTokenId); } + static string DealWithUriWithName(string str) + { + static uint32_t MEET_COUNT = 6; + uint32_t count = 0; + uint32_t index; + for (index = 0; index < str.length(); index++) { + if (str[index] == '/') { + count++; + } + if (count == MEET_COUNT) { + break; + } + } + if (count == MEET_COUNT) { + str = str.substr(0, index); + } + return str; + } + static string GetIdFromUri(string uri) { + uri = DealWithUriWithName(uri); string rowNum = ""; size_t pos = uri.rfind('/'); if (pos != string::npos) { -- Gitee