diff --git a/interfaces/kits/js/file_share/grant_uri_permission.cpp b/interfaces/kits/js/file_share/grant_uri_permission.cpp index c5432b8dd9f8c792f4d341b2629de817974caf5f..56a6d9d3b5522f587fa56f6c89f1c4ddbf35b866 100644 --- a/interfaces/kits/js/file_share/grant_uri_permission.cpp +++ b/interfaces/kits/js/file_share/grant_uri_permission.cpp @@ -40,8 +40,28 @@ namespace ModuleFileShare { return true; } + 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) {