fixed regression on router.baseUri

This commit is contained in:
Camel Aissani 2017-01-14 16:08:22 +01:00
parent a9b90040bd
commit abc9ffc405
5 changed files with 41 additions and 9 deletions

View File

@ -8,7 +8,7 @@
[![Code Climate](https://codeclimate.com/github/camelaissani/frontexpress/badges/gpa.svg)](https://codeclimate.com/github/camelaissani/frontexpress)
[![Coverage Status](https://coveralls.io/repos/github/camelaissani/frontexpress/badge.svg?branch=master)](https://coveralls.io/github/camelaissani/frontexpress?branch=master)
![dependencies](https://img.shields.io/gemnasium/mathiasbynens/he.svg)
![Size Shield](https://img.shields.io/badge/size-3.07kb-brightgreen.svg)
![Size Shield](https://img.shields.io/badge/size-3.17kb-brightgreen.svg)
Code the front-end logic with the same style than on the back-end with express

View File

@ -10,6 +10,22 @@ var HTTP_METHODS = ['GET', 'POST', 'PUT', 'DELETE'];
// not supported yet
// HEAD', 'CONNECT', 'OPTIONS', 'TRACE', 'PATCH';
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
var classCallCheck = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
@ -654,10 +670,18 @@ var Router = function () {
}, {
key: 'baseUri',
set: function set$$1(uri) {
if (this._baseUri) {
throw new TypeError('base uri is already set');
if (!uri) {
return;
}
if (!this._baseUri) {
this._baseUri = uri;
return;
}
if (_typeof(this._baseUri) !== (typeof uri === 'undefined' ? 'undefined' : _typeof(uri))) {
throw new TypeError('router cannot mix regexp and uri');
}
this._baseUri = uri;
}
/**

2
frontexpress.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -91,10 +91,18 @@ export default class Router {
*/
set baseUri(uri) {
if (this._baseUri) {
throw new TypeError('base uri is already set');
if (!uri) {
return;
}
if (!this._baseUri) {
this._baseUri = uri;
return;
}
if (typeof this._baseUri !== typeof uri) {
throw new TypeError('router cannot mix regexp and uri');
}
this._baseUri = uri;
}