whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: Fix up same safe_name
Date Sun, 04 Oct 2020 13:19:41 GMT
This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 927c1f4  Fix up same safe_name
927c1f4 is described below

commit 927c1f4598557b44817ae682dcd20c78c40707fc
Author: Sebb <sebb@apache.org>
AuthorDate: Sun Oct 4 14:19:33 2020 +0100

    Fix up same safe_name
    
    anchored gsub only applies once;
    seems no point dropping only the first non-word char
    what if there is more than one?
    
    Use %r{} to remove ambiguity with division operator
---
 www/secretary/workbench/models/attachment.rb | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/www/secretary/workbench/models/attachment.rb b/www/secretary/workbench/models/attachment.rb
index 8ed35af..a1fdcb5 100644
--- a/www/secretary/workbench/models/attachment.rb
+++ b/www/secretary/workbench/models/attachment.rb
@@ -39,8 +39,7 @@ class Attachment
 
   def safe_name
     name = self.name.dup
-    name.gsub! /^\W/, ''
-    name.gsub! /[^\w.]/, '_'
+    name.gsub! %r{[^\w.]}, '_'
     name
   end
 


Mime
View raw message