Skip to content

add slug with occurrences - #20

Merged
wooorm merged 5 commits into
Flet:masterfrom
UziTech:matching
Jan 8, 2019
Merged

add slug with occurrences#20
wooorm merged 5 commits into
Flet:masterfrom
UziTech:matching

Conversation

@UziTech

Copy link
Copy Markdown
Contributor

add slug with occurrences to the occurrences array to prevent collisions with text ending in a number

Fixes#19

@UziTech

Copy link
Copy Markdown
ContributorAuthor

right now I have it recursively check each slug with its occurrence to prevent collisions but I'm not sure if that is the best option. When a slug with an occurrence exists should it just add another occurrence or should it increment the occurrence.

varGithubSlugger=require('github-slugger')varslugger=newGithubSlugger()slugger.slug('foo-1')// returns 'foo-1'slugger.slug('foo')// returns 'foo'slugger.slug('foo')// returns 'foo-1-1'// should it return 'foo-2'?

@wooorm

Copy link
Copy Markdown
Collaborator

@UziTech For your question, that depends on what GH is doing! This project should match that. For an example, I’ve created a little markdown file that shows that to people in a PR here: #17

@UziTech

Copy link
Copy Markdown
ContributorAuthor

it looks like github sets the second foo to foo-2

@UziTech

Copy link
Copy Markdown
ContributorAuthor

I changed it so it matches github

varGithubSlugger=require('github-slugger')varslugger=newGithubSlugger()slugger.slug('foo-1')// returns 'foo-1'slugger.slug('foo')// returns 'foo'slugger.slug('foo')// returns 'foo-2'

@UziTechUziTech mentioned this pull request Dec 20, 2018
4 tasks
Sign up for freeto 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

@UziTech@wooorm@styfle