replace pasta.id == id to lambda function alias_comparator for better code reuse.
add custom_alias field in database
Why replace pasta.id == id
There are a large number of statements in the code that compare pasta.id == id, and implementing custom URL inevitably introduces additional fields, requiring a large number of duplicate judgments to be written at all positions. Therefore, I choose to extract the comparison logic into a lambda function to reduce duplicate code.
Support https://github.com/szabodanika/microbin/issues/83
What changed
pasta.id == id
to lambda functionalias_comparator
for better code reuse.custom_alias
field in databaseWhy replace pasta.id == id
There are a large number of statements in the code that compare
pasta.id == id
, and implementing custom URL inevitably introduces additional fields, requiring a large number of duplicate judgments to be written at all positions. Therefore, I choose to extract the comparison logic into a lambda function to reduce duplicate code.Todo
Custom URL validity check.