-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce duplication in badge regex/url patterns #2050
Comments
👍 Sounds like a good idea, would definitely help keep everything consistent. Edit: I like the look of |
I played with const pathToRegexp = require('path-to-regexp')
const keys = []
const re = pathToRegexp('/appveyor/ci/:user/:repo/:branch?.:ext(png|gif)', keys, {
delimiter: '.',
strict: true,
sensitive: true,
})
console.log(re)
const result = {}
re.exec('/appveyor/ci/foo/bar/baz.png').slice(1).forEach((match, i) => {
result[keys[i].name] = match
})
console.log(result) Output:
Cool stuff! The |
const toPath = pathToRegexp.compile('/appveyor/ci/:user/:repo/:branch?.:ext(png|gif)', {
delimiter: '.',
strict: true,
sensitive: true,
})
console.log(toPath({ user: 'foo', repo: 'bar', branch: 'baz', ext: 'png' })) What do you think? Should we move forward with this approach? |
This reduces duplication in badge regex/url patterns, and reduce the need to understand regexes in order to create badges. The badge examples could be harmonized to reduce the duplication even further, though that could be handled in a follow-on PR. Ref: #2050
This reduces duplication in badge regex/url patterns, and reduce the need to understand regexes in order to create badges. The badge examples could be harmonized to reduce the duplication even further, though that could be handled in a follow-on PR. Ref: #2050
This reduces duplication in badge regex/url patterns, and reduces the need to understand regexes in order to create badges. Ref: #2050
This continues the work from #2279, by allowing example badges to be specified using `namedParams`. Using an object makes it possible for us to display these in form fields down the line. (#701) I've called this the "preferred" way, and labeled the other ways deprecated. I've also added some doc to the `examples` property in BaseService. Then I realized we had some doc in the tutorial, though I think it's fine to have a short version in the tutorial, and the gory detail in BaseService. I've also added a `pattern` keyword, and made `urlPattern` an alias. Closes #2050.
Can we use something like url-pattern or path-to-regexp to define routes in a nicer way so we don't have to define this twice?
relevant discussions:
#2042 (comment)
#1582 (comment)
The text was updated successfully, but these errors were encountered: