1
0
Fork 0

Merge branch 'devel' of https://github.com/triAGENS/ArangoDB into devel

This commit is contained in:
Jan Steemann 2013-03-28 14:42:19 +01:00
commit 007cae87e6
6 changed files with 30 additions and 12 deletions

View File

@ -23,8 +23,8 @@ exports.mimeTypes = {
"html": [ "text/html", true ],
"htm": [ "text/html", true ],
"pdf": [ "application/pdf", false ],
"text": [ "text/plain", true ],
"txt": [ "text/plain", true ],
"text": [ "text/plain", true ],
"xml": [ "application/xml", true ]
};
@ -35,7 +35,7 @@ exports.extensions = {
"image/x-icon": [ "ico" ],
"image/gif": [ "gif" ],
"image/jpg": [ "jpg" ],
"text/plain": [ "text", "txt" ],
"text/plain": [ "txt", "text" ],
"application/xml": [ "xml" ],
"application/json": [ "json" ],
"text/css": [ "css" ],

View File

@ -22,8 +22,8 @@ exports.mimeTypes = {
"html": [ "text/html", true ],
"htm": [ "text/html", true ],
"pdf": [ "application/pdf", false ],
"text": [ "text/plain", true ],
"txt": [ "text/plain", true ],
"text": [ "text/plain", true ],
"xml": [ "application/xml", true ]
};
@ -34,7 +34,7 @@ exports.extensions = {
"image/x-icon": [ "ico" ],
"image/gif": [ "gif" ],
"image/jpg": [ "jpg" ],
"text/plain": [ "text", "txt" ],
"text/plain": [ "txt", "text" ],
"application/xml": [ "xml" ],
"application/json": [ "json" ],
"text/css": [ "css" ],

View File

@ -304,7 +304,21 @@ function DocumentationAndConstraintsSpec () {
assertEqual(routes[0].docs.notes, "c");
},
testDefineSummaryRestrictedTo60Characters: function () {
testNicknameFormat: function () {
var error;
try {
app.get('/foxx', function () {
//nothing
}).nickname("a b");
} catch(e) {
error = e;
}
assertEqual(error, "Nickname may only contain [a-z]");
},
testSummaryRestrictedTo60Characters: function () {
var error;
try {

View File

@ -504,6 +504,9 @@ _.extend(RequestContext.prototype, {
nickname: function (nickname) {
'use strict';
if (!nickname.match(/^[a-z]+$/)) {
throw "Nickname may only contain [a-z]";
}
this.route.docs.nickname = nickname;
return this;
},
@ -741,6 +744,7 @@ FormatMiddleware = function (allowedFormats, defaultFormat) {
determinePathAndFormat = function (path, headers) {
var mimeTypes = require("org/arangodb/mimetypes").mimeTypes,
extensions = require("org/arangodb/mimetypes").extensions,
urlFormatToMime = function (urlFormat) {
var mimeType;
@ -755,11 +759,11 @@ FormatMiddleware = function (allowedFormats, defaultFormat) {
mimeToUrlFormat = function (mimeType) {
var urlFormat;
urlFormat = {
"application/json": "json",
"text/html": "html",
"text/plain": "txt"
}[mimeType];
if (extensions[mimeType]) {
urlFormat = extensions[mimeType][0];
} else {
urlFormat = undefined;
}
return urlFormat;
},

View File

@ -12,7 +12,7 @@
"html","text/html",true
"htm","text/html",true
"pdf","application/pdf",false
"text","text/plain",true
"txt","text/plain",true
"text","text/plain",true
"xml","application/xml",true

View File

@ -25,8 +25,8 @@ void TRI_InitialiseEntriesMimetypes (void) {
TRI_RegisterMimetype("html", "text/html", true);
TRI_RegisterMimetype("htm", "text/html", true);
TRI_RegisterMimetype("pdf", "application/pdf", false);
TRI_RegisterMimetype("text", "text/plain", true);
TRI_RegisterMimetype("txt", "text/plain", true);
TRI_RegisterMimetype("text", "text/plain", true);
TRI_RegisterMimetype("xml", "application/xml", true);
}