fix(uriproxy): better extractor

This commit is contained in:
əlemi 2024-05-20 08:45:59 +02:00
parent 1a236589ed
commit b6e48025fb
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -39,8 +39,10 @@ pub fn uri(base: &str, entity: UriClass, id: &str) -> String {
/// decompose local id constructed by uri() fn
pub fn decompose_id(full_id: &str) -> String {
full_id // https://example.org/users/test/followers/page?offset=42
.split('/') // ['https:', '', 'example.org', 'users', 'test', 'followers', 'page?offset=42' ]
.nth(4) // 'test'
.replace("https://", "")
.replace("http://", "")
.split('/') // ['example.org', 'users', 'test', 'followers', 'page?offset=42' ]
.nth(2) // 'test'
.unwrap_or("")
.to_string()
}