From 3b72c497fee8b9c8837eedd9c0e24fa97b684385 Mon Sep 17 00:00:00 2001 From: chiu Date: Mon, 6 Sep 2021 05:54:59 +0000 Subject: [PATCH] fix error --- gallery.gemspec | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gallery.gemspec b/gallery.gemspec index 29882bb..06ba66e 100644 --- a/gallery.gemspec +++ b/gallery.gemspec @@ -26,9 +26,10 @@ if bundle_update_flag update_flag = false last_index = widget_info[-1]["filename"].match(/\d+/)[0].to_i rescue nil if !last_index.nil? + idx_regex = /^(\d+[\. \t]*)|[ \t]+$/ default_gallery_widget_info.each do |h| - name_without_index = h["name"]["zh_tw"].sub(/\d+/,'') - widget_info_index = (widget_info.index{|hh| hh["name"]["zh_tw"].include?(name_without_index)} rescue -1) + name_without_index = h["name"]["zh_tw"].gsub(idx_regex,'') + widget_info_index = (widget_info.index{|hh| hh["name"]["zh_tw"].gsub(idx_regex,'') == name_without_index}||-1 rescue -1) if (widget_info_index == -1 || widget_info_index.nil?) update_flag = true copy_h = h.dup