contentful-database-importer.rb
contentful-database-importer.rb copied to clipboard
Truncate ID to 64 chars
Updated asset_id_from_name
to truncate the returned id to 64 characters as Contentful's API doesn't allow more than 64 characters. See https://www.contentful.com/developers/docs/references/content-management-api/#/introduction/resource-ids
Hey @cachrisman,
Thanks for the contribution.
There are 2 things that raise warnings from this and would love to have improved:
-
This will allow for collisions, E.g.
a_veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeery_long_asset_name_1
anda_veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeery_long_asset_name_2
would both get truncated toa_veeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeery_long_asset_name
leading to a collision which we do not want. Better have it then SHA1 hash it + base62 encode it or something alike on longer IDs so that this issue is avoided. -
Please add a test so that we can check that the asset ID is being generated as expected.
Please let me know if you can do this changes.
Cheers