Escape ext in RegExp from fs.base

This commit is contained in:
Kevin Sawicki
2013-01-08 13:31:37 -08:00
parent 594813be34
commit fee1e7bc8b
2 changed files with 8 additions and 1 deletions

View File

@@ -15,7 +15,7 @@ module.exports =
# remove a trailing extension.
base: (path, ext) ->
base = path.replace(/\/$/, '').split("/").pop()
if ext then base.replace(RegExp(ext + "$"), "") else base
if ext then base.replace(RegExp("#{_.escapeRegExp(ext)}$"), '') else base
# Returns the path of a file's containing directory, albeit the
# parent directory if the file is a directory. A terminal directory