Factor out maybe_remove_extension/1 function COUCHDB-3080
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/6b1796f9 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/6b1796f9 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/6b1796f9 Branch: refs/heads/master Commit: 6b1796f9589eafeb0bc89b4f446915a1a71c7282 Parents: 1df597f Author: ILYA Khlopotov <iil...@ca.ibm.com> Authored: Mon Jul 25 15:22:04 2016 -0700 Committer: ILYA Khlopotov <iil...@ca.ibm.com> Committed: Tue Aug 9 15:27:48 2016 -0700 ---------------------------------------------------------------------- src/couch_db.erl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/6b1796f9/src/couch_db.erl ---------------------------------------------------------------------- diff --git a/src/couch_db.erl b/src/couch_db.erl index 3eff99f..229bf4f 100644 --- a/src/couch_db.erl +++ b/src/couch_db.erl @@ -1519,13 +1519,17 @@ select_lt(V1, _V2) -> V1. normalize_dbname(DbName) when is_list(DbName) -> normalize_dbname(list_to_binary(DbName)); normalize_dbname(DbName) when is_binary(DbName) -> + mem3:dbname(maybe_remove_extension(DbName)). + +maybe_remove_extension(DbName) -> case filename:extension(DbName) of <<".couch">> -> - mem3:dbname(filename:rootname(DbName)); + filename:rootname(DbName); _ -> - mem3:dbname(DbName) + DbName end. + -spec dbname_suffix(list() | binary()) -> binary(). dbname_suffix(DbName) ->