I am building a service where users installs a plugin across all of their pages on their site (such as by adding it to their template) but I only want to run the plugin code on a specific URL or pattern of URLs provided by the site owner.
I would like to allow the site owner to be able to set a simple sort of URL pattern (for example, similar to how Cloudflare does it):
For example, The site owner could set a URL pattern as: https://example.com/pages/*/edit
And save this pattern in the db, like so:
@url = Url.create string: 'https://example.com/pages/*/edit'
Say then a user visits the url https://example.com/pages/my-page/edit
I want to pass this back to my app and somehow find the previously created @url
with that specific URL.
Url.find_by_url 'https://example.com/pages/my-page/edit'
Should then return the previously created Url
record.
How would you go about doing this?