summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Christopher Anderson <jchris@apache.org>2009-03-06 00:20:53 +0000
committerJohn Christopher Anderson <jchris@apache.org>2009-03-06 00:20:53 +0000
commitb64710f6e894fc70c962c2ea2493accfb3738652 (patch)
tree5ccd6371298843523856b15adf29abc7263d70ea
parenta05797474397a1598ac2e3436bd8c1e4e2b8678a (diff)
tiny refactor of validate_attachment_name for pattern matching
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@750699 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/couchdb/couch_httpd_db.erl8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl
index 0ba8a873..005e32d1 100644
--- a/src/couchdb/couch_httpd_db.erl
+++ b/src/couchdb/couch_httpd_db.erl
@@ -720,13 +720,11 @@ validate_attachment_names(Doc) ->
validate_attachment_name(Name) when is_list(Name) ->
validate_attachment_name(list_to_binary(Name));
+validate_attachment_name(<<"_",_/binary>>) ->
+ throw({bad_request, <<"Attachment name can't start with '_'">>});
validate_attachment_name(Name) ->
case is_valid_utf8(Name) of
- true ->
- case Name of
- <<"_",_/binary>>=Name -> throw({bad_request, <<"Attachment name can't start with '_'">>});
- _ -> Name
- end;
+ true -> Name;
false -> throw({bad_request, <<"Attachment name is not UTF-8 encoded">>})
end.