-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat: allow for second parameter on getSlug function for allowed char… #6695
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
Conversation
…acters Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
🦋 Changeset detectedLatest commit: 71d29a4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
packages/api-utils/lib/getSlug.js
Outdated
@@ -4,14 +4,17 @@ const require = createRequire(import.meta.url); | |||
|
|||
const { slugify } = require("transliteration"); | |||
|
|||
const standardSlug = "a-zA-Z0-9-"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default allowedChars
based on the transliteration documentation is a-zA-Z0-9-_.~'
packages/api-utils/lib/getSlug.js
Outdated
/** | ||
* @name getSlug | ||
* @summary Return a slugified string using "slugify" from transliteration | ||
* @see https://www.npmjs.com/package/transliteration | ||
* @memberof Utils | ||
* @param {String} slugString - string to slugify | ||
* @param {String|Boolean} allowedChars - specify extra characters that are not removed by slugify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The official JSDocs syntax for optional parameter with default value:
* @param {String|Boolean} allowedChars - specify extra characters that are not removed by slugify | |
* @param {String} [allowedChars=a-zA-Z0-9-_.~'] - specify extra characters that are not removed by slugify |
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
Signed-off-by: Brent Hoover brent@thebuddhalodge.com
Impact: minor
Type: bugfix
Issue
getSlug in Tags needs to incorporate slashes however we should not change the global behavior which affects many other items
Solution
Provide a second parameter which allows you to specify allowedChar
Breaking changes
None
Testing
You should be able to create a tag with a slash in the name and have it retain the slash