mirror of
https://github.com/YGGverse/Yoda.git
synced 2026-04-01 00:55:28 +00:00
remove scheme from scope, rename build constructors
This commit is contained in:
parent
9371f16798
commit
089a91d5a2
25 changed files with 103 additions and 72 deletions
|
|
@ -65,8 +65,10 @@ impl Memory {
|
|||
let mut result = Vec::new();
|
||||
|
||||
// Get all records starts with `scope`
|
||||
let query = filter_scope(request);
|
||||
|
||||
for (scope, &profile_identity_id) in self.index.borrow().iter() {
|
||||
if request.starts_with(scope) {
|
||||
if query.starts_with(scope) {
|
||||
result.push(Auth {
|
||||
profile_identity_id,
|
||||
scope: scope.clone(),
|
||||
|
|
@ -81,3 +83,24 @@ impl Memory {
|
|||
result.first().cloned()
|
||||
}
|
||||
}
|
||||
|
||||
/// Get valid identity scope for given URL
|
||||
/// * helper function for different protocol drivers implementation
|
||||
fn filter_scope(url: &str) -> String {
|
||||
use gtk::glib::{Regex, RegexCompileFlags, RegexMatchFlags};
|
||||
|
||||
match Regex::split_simple(
|
||||
r"^\w+://(.*)",
|
||||
url,
|
||||
RegexCompileFlags::DEFAULT,
|
||||
RegexMatchFlags::DEFAULT,
|
||||
)
|
||||
.get(1)
|
||||
{
|
||||
Some(postfix) => postfix.to_string(),
|
||||
None => url.to_string(),
|
||||
}
|
||||
.trim()
|
||||
.trim_end_matches("/")
|
||||
.to_lowercase()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue