anegostudios/vsapi

Suggestion for wildcard matching

jacopouggeri opened this issue · 4 comments

Spent some time getting confused why my item codes weren't matching, then I realised RegistryObject.WildcardMatch only checks the Path and not the Domain. Just a small modification, but it would be nice to have this available natively within the api to easily match modded items. Here is how I modified it for my purposes:

public static bool WildCardMatchDomain(this CollectibleObject collectible, string wildCard)
    {
        if (collectible.Code == null)
        {
            return false;
        }

        // Split the wildCard string into domain and path
        string[] parts = wildCard.Split(':');
        if (parts.Length != 2)
        {
            return false;
        }

        string domain = parts[0];
        string path = parts[1];
        
        // Match the domain and path separately
        return domain == collectible.Code.Domain && WildcardUtil.Match(path, collectible.Code.Path);
    }

@jayugg
Works for me

"@(game|loreweapons):axe-(.*)"
WildcardUtil.Match(GroundRackableCodes, obj.Code.ToString())

To match any domain use something like this:

"@*:axe-.*"
"*:axe-*"

@jayugg Works for me

"@(game|loreweapons):axe-(.*)"
WildcardUtil.Match(GroundRackableCodes, obj.Code.ToString())

Oh, so you need this specific syntax wih the parentheses to match a domain? Because it didn't work for me if I just did modid:axe