Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
paperclip
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ikcrm_common
paperclip
Commits
cc89e4aa
Commit
cc89e4aa
authored
Oct 03, 2011
by
Iain Beeston
Committed by
Iain Beeston
Oct 04, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Escaped strings that are inserted into regexps during interpolation
parent
7f523e35
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletions
+8
-1
lib/paperclip/interpolations.rb
+1
-1
test/interpolations_test.rb
+7
-0
No files found.
lib/paperclip/interpolations.rb
View file @
cc89e4aa
...
...
@@ -86,7 +86,7 @@ module Paperclip
# Returns the basename of the file. e.g. "file" for "file.jpg"
def
basename
attachment
,
style_name
attachment
.
original_filename
.
gsub
(
/
#{
File
.
extname
(
attachment
.
original_filename
)
}
$/
,
""
)
attachment
.
original_filename
.
gsub
(
/
#{
Regexp
.
escape
(
File
.
extname
(
attachment
.
original_filename
)
)
}
$/
,
""
)
end
# Returns the extension of the file. e.g. "jpg" for "file.jpg"
...
...
test/interpolations_test.rb
View file @
cc89e4aa
...
...
@@ -154,6 +154,13 @@ class InterpolationsTest < Test::Unit::TestCase
attachment
.
stubs
(
:original_filename
).
returns
(
"one"
)
assert_equal
"one"
,
Paperclip
::
Interpolations
.
filename
(
attachment
,
:style
)
end
should
"return the basename when the extension contains regexp special characters"
do
attachment
=
mock
attachment
.
stubs
(
:styles
).
returns
({})
attachment
.
stubs
(
:original_filename
).
returns
(
"one.ab)"
)
assert_equal
"one"
,
Paperclip
::
Interpolations
.
basename
(
attachment
,
:style
)
end
should
"return the timestamp"
do
now
=
Time
.
now
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment