1. Benoit Chesneau
  2. couchdb

Commits

J. Chris Anderson  committed 8ecf01a

tiny refactor of validate_attachment_name for pattern matching

  • Participants
  • Parent commits 7c21b27
  • Branches default

Comments (0)

Files changed (1)

File src/couchdb/couch_httpd_db.erl

View file
 
 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.