diff --git a/lib/eeepub/opf.rb b/lib/eeepub/opf.rb index 237ad45..3beb00a 100644 --- a/lib/eeepub/opf.rb +++ b/lib/eeepub/opf.rb @@ -137,14 +137,12 @@ def complete_manifest def create_unique_item_id(filename, id_cache) basename = File.basename(filename) - unless id_cache[basename] - id_cache[basename] = 0 - name = basename - else - name = "#{basename}-#{id_cache[basename]}" - end + id_cache[basename] ||= 0 + name = "id-#{basename}-#{id_cache[basename]}".gsub(/[^a-zA-Z0-9\-.]/, '-') + id_cache[basename] += 1 - name + + return name end end end