Skip to content

Conversation

@stevenjoezhang
Copy link
Member

check list

  • Add test cases for the changes.
  • Passed the CI test.

Description

See #147

Additional information

@coveralls
Copy link

coveralls commented Apr 18, 2024

Pull Request Test Coverage Report for Build 8733513242

Details

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 98.274%

Totals Coverage Status
Change from base Build 7520284387: 0.0%
Covered Lines: 4385
Relevant Lines: 4462

💛 - Coveralls

tomap
tomap previously approved these changes Apr 18, 2024
Copy link
Member

@SukkaW SukkaW left a comment

Choose a reason for hiding this comment

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

nanoid LGTM. It is faster and is collision resilient enough.

Comment on lines 31 to 34
validate(value?: string): string {
if (value && (value[0] !== 'c' || value.length !== 25)) {
if (value && (value.length !== 21)) {
throw new ValidationError(`\`${value}\` is not a valid CUID`);
}
Copy link
Member

@SukkaW SukkaW Apr 18, 2024

Choose a reason for hiding this comment

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

Since the schema of the id has changed, previously generated db.json will become invalid after the PR. It is a breaking change that we might want to avoid.

Let's keep the c prefix, and let the nanoid generate random ids with the size of 24. Now previously generated db.json is still valid and Hexo will not crash.

Copy link
Member Author

Choose a reason for hiding this comment

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

That makes sense. I will change its format to be compatible with old cuid.

@SukkaW SukkaW merged commit d6301c4 into master Apr 18, 2024
@SukkaW SukkaW deleted the nanoid branch April 18, 2024 06:56
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.

5 participants