-
-
Notifications
You must be signed in to change notification settings - Fork 81
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
Add leading underscore option #43
Changes from 3 commits
64d6bbc
0c20cd6
9348c29
ee0cf26
ea9be90
e071769
35b8da5
ed03eeb
85209f8
781c37e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -132,6 +132,23 @@ slugify('foo@unicorn', { | |
//=> 'foo-at-unicorn' | ||
``` | ||
|
||
##### preserveLeadingUnderscore | ||
|
||
Type: `boolean`\ | ||
Default: `false` | ||
|
||
If your string starts with an underscore, it will be preserved in the slugified string. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You need to keep the readme in sync with the index.d.ts docs. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it would also be useful to include a use-case for this option, as mentioned by the original issue. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I have just added an example as a hidden_filename to give this idea There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I should have been clearer, by use-case, I meant a written use-case, not a code example. I don't think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right. and if I just update the description to: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still don't think that's very clear. You could almost just copy-paste the comment from the original issue:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, perfect! done that! |
||
|
||
```js | ||
const slugify = require('@sindresorhus/slugify'); | ||
|
||
slugify('_foo_bar'); | ||
//=> 'foo-bar' | ||
|
||
slugify('_foo_bar', {preserveLeadingUnderscore: true}); | ||
//=> '_foo-bar' | ||
``` | ||
|
||
## Related | ||
|
||
- [slugify-cli](https://github.com/sindresorhus/slugify-cli) - CLI for this module | ||
|
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.
This check should be done before any string transformations are done.
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.
Indeed! Done.