Skip to content

add slug with occurrences - #20

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

wooorm merged 5 commits into
Flet:masterfrom
UziTech:matching

Conversation

@UziTech

@UziTech UziTech commented Dec 3, 2018

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

UziTech commented Dec 3, 2018

Copy link
Copy Markdown
Contributor Author

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.

var GithubSlugger = require('github-slugger')
var slugger = new GithubSlugger()

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

wooorm commented Dec 3, 2018

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

UziTech commented Dec 3, 2018

Copy link
Copy Markdown
Contributor Author

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

@UziTech

UziTech commented Dec 3, 2018

Copy link
Copy Markdown
Contributor Author

I changed it so it matches github

var GithubSlugger = require('github-slugger')
var slugger = new GithubSlugger()

slugger.slug('foo-1')
// returns 'foo-1'

slugger.slug('foo')
// returns 'foo'

slugger.slug('foo')
// returns 'foo-2'

@UziTech UziTech mentioned this pull request Dec 20, 2018
4 tasks done
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