Is there a built-in function for a matching a URL against a matches value in permissions?

Is there a built-in Javascript function or one in the WebExtension APIs for a matching a URL against a matches value in permissions?

For example - matching https://discourse.mozilla.org/c/add-ons against *://*.mozilla.org/*?

There is not, no. Match patterns can only be passed as params to things like content script or webReqeust filters.

And you can e.g. check whether your add-on has a specific (host) permission, i.e. match pattern, via permissions.contains.