Skip to content
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

Allow For Previous Occurrences To Be Imported When Initiating Class #50

Closed
wants to merge 2 commits into from

Conversation

sampoder
Copy link

This would be helpful if you've got a bunch of slugs in a database and you want to make more

@sampoder
Copy link
Author

Hopefully that works! :D

obj[strippedSlug] = (obj[strippedSlug] || 0) + 1;
return obj;
}, {});
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey!

  • how do you want to save this stuff to a database?
  • the strippedSlug part comes with a bug: what if someone writes a heading ## Heading 1?
  • I think the this.reset below overwrites all your changes
  • docs and tests!
  • lastly, the previous points can be addressed first, but there’s also a security problem here: a slug of constructor will be injected into the object, and cause problems!

I’d first like to hear more about your use case.
Perhaps we can come up with a different API. Maybe like a slugger.toJSON() function which yields the map, and a Slugger.fromJSON(map) to revive it?

@sampoder
Copy link
Author

sampoder commented Oct 4, 2023

Hey @wooorm! Thanks for the review, apologies for the delayed response!

how do you want to save this stuff to a database?

At the moment, we've got a bunch of rows each with a slug in the slug column.

the strippedSlug part comes with a bug: what if someone writes a heading ## Heading 1?

I think the this.reset below overwrites all your changes

LOL yes! good catch.

docs and tests!

certainly, I'll add these once everything else is ready to go

lastly, the previous points can be addressed first, but there’s also a security problem here: a slug of constructor will be injected into the object, and cause problems!

oh fun, what do you exactly mean? a slug that's like "constructor" or something else.

I’d first like to hear more about your use case.

Basically, we have a bunch of events which each need a unique slug for their page on our site but we want to prevent duplicate slugs.

Perhaps we can come up with a different API. Maybe like a slugger.toJSON() function which yields the map, and a Slugger.fromJSON(map) to revive it?

I like this idea! Let me work on creating a new branch and doing this instead.

@wooorm
Copy link
Collaborator

wooorm commented Oct 26, 2023

Do you still need this? Still plan to work on it? How can I help?

@sampoder
Copy link
Author

sampoder commented Nov 3, 2023

Hey! Sorry for the long delay, one day I might get back to this. We no longer need it for this specific project but I do think it'll be cool... hopefully one day I'll be back with a new PR to solve this :D

@sampoder sampoder closed this Nov 3, 2023
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.

2 participants