+
Skip to content

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

Merged
merged 6 commits into from
Dec 9, 2022

Conversation

brent-hoover
Copy link
Collaborator

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

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

…acters

Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
@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
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
Signed-off-by: Brent Hoover <brent@thebuddhalodge.com>
@@ -4,14 +4,17 @@ const require = createRequire(import.meta.url);

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

/**
* @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
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 <brent@thebuddhalodge.com>
@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.

3 participants
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载