Skip to content

Conversation

@brent-hoover
Copy link
Collaborator

@brent-hoover brent-hoover commented Dec 9, 2022

Signed-off-by: Brent Hoover [email protected]

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

@changeset-bot
Copy link

changeset-bot bot commented Dec 9, 2022

🦋 Changeset detected

Latest commit: 71d29a4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@reactioncommerce/api-plugin-tags Patch
@reactioncommerce/api-utils Patch
reaction Patch

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

Brent Hoover and others added 3 commits December 9, 2022 01:00

const { slugify } = require("transliteration");

const standardSlug = "a-zA-Z0-9-";
Copy link
Collaborator

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-_.~'

* @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
Copy link
Collaborator

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:

Suggested change
* @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 <[email protected]>
@brent-hoover brent-hoover merged commit cdd9723 into trunk Dec 9, 2022
@brent-hoover brent-hoover deleted the allowed-characters-in-getslug branch December 9, 2022 09:15
This was referenced Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants