diff --git a/CHANGELOG.md b/CHANGELOG.md index f11413b8..b08ad141 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based now on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 3.4.1 — 2024-03-24 + +### Fixed + +* Fixed invalid group id error when >= 10 files are uploaded when using `mount_uploadcare_file_group`. + ## 3.4.0 — 2024-03-05 ### Fixed diff --git a/README.md b/README.md index e0ac9c34..cc9cf78d 100644 --- a/README.md +++ b/README.md @@ -287,7 +287,7 @@ The helper is detecting the value of the `multiple` property based on the mount ### File and Group wrappers When you mount either Uploadcare File or Group to an attribute, this attribute is getting wrapped with -a Uploadcare object. This feature adds some usefull methods to the attribute. +a Uploadcare object. This feature adds some useful methods to the attribute. #### Uploadcare File @@ -300,7 +300,7 @@ class Post < ApplicationRecord end ``` -And then you create a new Post object specifying a CDN-url for your prevously uploaded Uploadcare file: +And then you create a new Post object specifying a CDN-url for your previously uploaded Uploadcare file: ```console $ post = Post.create(picture: "https://ucarecdn.com/2d33999d-c74a-4ff9-99ea-abc23496b052/") diff --git a/lib/uploadcare/rails/active_record/mount_uploadcare_file_group.rb b/lib/uploadcare/rails/active_record/mount_uploadcare_file_group.rb index 9d2fe105..4a50bc16 100644 --- a/lib/uploadcare/rails/active_record/mount_uploadcare_file_group.rb +++ b/lib/uploadcare/rails/active_record/mount_uploadcare_file_group.rb @@ -13,7 +13,7 @@ module ActiveRecord module MountUploadcareFileGroup extend ActiveSupport::Concern - GROUP_ID_REGEX = /\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b~\d/.freeze + GROUP_ID_REGEX = /\b[0-9a-f]{8}\b-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-\b[0-9a-f]{12}\b~\d+/.freeze def build_uploadcare_file_group(attribute) cdn_url = attributes[attribute.to_s].to_s diff --git a/lib/uploadcare/rails/version.rb b/lib/uploadcare/rails/version.rb index bc960928..cef1375f 100644 --- a/lib/uploadcare/rails/version.rb +++ b/lib/uploadcare/rails/version.rb @@ -2,6 +2,6 @@ module Uploadcare module Rails - VERSION = '3.4.0' + VERSION = '3.4.1' end end diff --git a/spec/uploadcare/rails/active_record/mount_uploadcare_group_spec.rb b/spec/uploadcare/rails/active_record/mount_uploadcare_group_spec.rb index 9dc6be9b..fc265e41 100644 --- a/spec/uploadcare/rails/active_record/mount_uploadcare_group_spec.rb +++ b/spec/uploadcare/rails/active_record/mount_uploadcare_group_spec.rb @@ -29,4 +29,18 @@ def initialize expect(Post).to respond_to(:has_uploadcare_file_group_for_gallery?) end end + + describe 'GROUP_ID_REGEX' do + it 'properly extracts out group id from the cdn url' do + extracted_group_id = Uploadcare::Rails::IdExtractor.call( + 'https://ucarecdn.com/dc140069-62b1-4ee0-b603-18e2062e26e4~11/', subject::GROUP_ID_REGEX + ) + expect(extracted_group_id).to eq('dc140069-62b1-4ee0-b603-18e2062e26e4~11') + + extracted_group_id = Uploadcare::Rails::IdExtractor.call( + 'https://ucarecdn.com/dc140069-62b1-4ee0-b603-18e2062e26e4~1/', subject::GROUP_ID_REGEX + ) + expect(extracted_group_id).to eq('dc140069-62b1-4ee0-b603-18e2062e26e4~1') + end + end end