Closed ronald2wing closed 4 months ago
It's a UUID so can be easily matched with a regular expression, so you could use something like this - note that there's a property friendly_id_config.sequence_separator
if you use something other than -
:
irb(main):003> "some-random-slug-123e4567-e89b-12d3-a456-426614174000".partition(/\-[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\z/i)
=> ["some-random-slug", "-123e4567-e89b-12d3-a456-426614174000", ""]
irb(main):004> "some-random-slug-123e4567-e89b-12d3-a456-426614174000".partition(/\-[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}\z/i).first
=> "some-random-slug"
Let's say you have duplicated pages with duplicated URLs. You'd like to point the duplicated URLs to the one without the GUID hash. How would you do that?