I\'m looking for a way to make sure that all of my urls end with a trailing slash (so first check if there is already a trailing slash at the end, and if not add one).
I
The following regex handles query string as well:
redirect: [ { from: '^(\\/[^\\?]*[^\\/])(\\?.*)?$', to: '$1/$2', }, ],
You can try to match only those URLs that do not end with a slash:
redirect: [ { from: '^.*(?<!\/)$', to: (from, req) => req.url + '/' } ]