Skip to content

Commit 340d018

Browse files
committed
Stable Version 0.4.1.
1 parent 9a3d13d commit 340d018

File tree

10 files changed

+78
-61
lines changed

10 files changed

+78
-61
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
##### 0.4.1 - 30 September 2014
2+
3+
###### Backwards compatible API changes
4+
- Added `forceTrailingSlash` option to `DSHttpAdapter#defaults`
5+
16
##### 0.4.0 - 25 September 2014
27

38
###### Breaking API changes

README.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ Load `js-data-http.js` after `js-data.js`.
3030
var adapter = new DSHttpAdapter();
3131

3232
var store = new JSData.DS();
33-
34-
store.defaults.DSHttpAdapter = adapter;
35-
store.defaults.defaultAdapter = 'DSHttpAdapter';
33+
store.registerAdapter('http', adapter, { default: true });
3634

3735
// "store" will now use the http adapter for all async operations
3836
```
@@ -61,21 +59,25 @@ First, feel free to contact me with questions. [Mailing List](https://groups.io/
6159

6260
## License
6361

62+
The MIT License (MIT)
63+
6464
Copyright (c) 2014 Jason Dobry
6565

66-
Permission is hereby granted, free of charge, to any person obtaining a copy of
67-
this software and associated documentation files (the "Software"), to deal in
68-
the Software without restriction, including without limitation the rights to
69-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
70-
of the Software, and to permit persons to whom the Software is furnished to do
71-
so, subject to the following conditions:
66+
Permission is hereby granted, free of charge, to any person obtaining a copy
67+
of this software and associated documentation files (the "Software"), to deal
68+
in the Software without restriction, including without limitation the rights
69+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
70+
copies of the Software, and to permit persons to whom the Software is
71+
furnished to do so, subject to the following conditions:
7272

7373
The above copyright notice and this permission notice shall be included in all
7474
copies or substantial portions of the Software.
7575

7676
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
77-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
78-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
79-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
80-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
81-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
77+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
78+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
79+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
80+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
81+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
82+
SOFTWARE.
83+

bower.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "js-data-http",
33
"description": "http adapter for js-data.",
4-
"version": "0.4.0",
4+
"version": "0.4.1",
55
"homepage": "http://www.js-data.io/js-data-http",
66
"repository": {
77
"type": "git",
@@ -30,9 +30,9 @@
3030
"karma.start.js"
3131
],
3232
"peerDependencies": {
33-
"js-data": "0.0.1"
33+
"js-data": "~0.4.x"
3434
},
3535
"devDependencies": {
36-
"js-data": "~0.0.1"
36+
"js-data": "~0.4.x"
3737
}
3838
}

dist/js-data-http.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @author Jason Dobry <[email protected]>
33
* @file js-data-http.js
4-
* @version 0.4.0 - Homepage <http://www.js-data.iojs-data-http/>
4+
* @version 0.4.1 - Homepage <http://www.js-data.iojs-data-http/>
55
* @copyright (c) 2014 Jason Dobry
66
* @license MIT <https://github.com/js-data/js-data-http/blob/master/LICENSE>
77
*
@@ -1312,6 +1312,8 @@ defaultsPrototype.queryTransform = function (resourceName, params) {
13121312

13131313
defaultsPrototype.basePath = '';
13141314

1315+
defaultsPrototype.forceTrailingSlash = '';
1316+
13151317
defaultsPrototype.httpConfig = {};
13161318

13171319
defaultsPrototype.log = console ? console.log : function () {
@@ -1343,7 +1345,10 @@ dsHttpAdapterPrototype.getAllPath = function (resourceConfig, options) {
13431345
dsHttpAdapterPrototype.HTTP = function (config) {
13441346
var _this = this;
13451347
var start = new Date().getTime();
1346-
config = deepMixIn(config, this.defaults.httpConfig);
1348+
config = deepMixIn(config, _this.defaults.httpConfig);
1349+
if (_this.defaults.forceTrailingSlash && config.url[config.url.length] !== '/') {
1350+
config.url += '/';
1351+
}
13471352
return http(config).then(function (data) {
13481353
if (_this.defaults.log) {
13491354
var args = Array.prototype.slice.call(arguments);

dist/js-data-http.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/example.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
(function () {
2-
var dsHttpAdapter = new DSHttpAdapter();
2+
var adapter = new DSHttpAdapter();
33

4-
var datastore = new JSData.DS();
5-
datastore.defaults.defaultAdapter = 'dsHttpAdapter';
6-
datastore.adapters.dsHttpAdapter = dsHttpAdapter;
4+
var store = new JSData.DS();
5+
store.registerAdapter('http', adapter, { default: true });
76

8-
var User = datastore.defineResource('user');
7+
var User = store.defineResource('user');
98

109
angular.module('http-example', [])
1110
.controller('httpCtrl', function ($scope, $timeout) {

example/index.html

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<title></title>
66
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
77
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js"></script>
8-
<script src="https://github.com/js-data/js-data/releases/download/0.0.1/js-data-0.0.1.min.js"></script>
8+
<script src="https://github.com/js-data/js-data/releases/download/0.4.0/js-data-0.4.0.min.js"></script>
99
<script
10-
src="https://github.com/js-data/js-data-http/releases/download/0.1.0/js-data-http-0.1.0.min.js"></script>
10+
src="https://github.com/js-data/js-data-http/releases/download/0.4.1/js-data-http-0.4.1.min.js"></script>
1111
<script src="./example.js"></script>
1212
</head>
1313
<body data-ng-controller="httpCtrl as lsCtrl">
@@ -42,13 +42,12 @@ <h3 class="panel-title">Users</h3>
4242
</div>
4343
<div>
4444
<pre><code>
45-
var dsHttpAdapter = new DSHttpAdapter();
45+
var adapter = new DSHttpAdapter();
4646

47-
var datastore = new JSData.DS();
48-
datastore.defaults.defaultAdapter = 'dsHttpAdapter';
49-
datastore.adapters.dsHttpAdapter = dsHttpAdapter;
47+
var store = new JSData.DS();
48+
store.registerAdapter('http', adapter, { default: true });
5049

51-
var User = datastore.defineResource('user');
50+
var User = store.defineResource('user');
5251

5352
angular.module('http-example', [])
5453
.controller('httpCtrl', function ($scope, $timeout) {

karma.start.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ beforeEach(function () {
5656
dsHttpAdapter = new DSHttpAdapter({
5757
queryTransform: queryTransform
5858
});
59+
datastore.registerAdapter('http', dsHttpAdapter, { default: true });
60+
5961
queryTransform.callCount = 0;
6062

6163
p1 = { author: 'John', age: 30, id: 5 };

package.json

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "js-data-http",
33
"description": "http adapter for js-data.",
4-
"version": "0.4.0",
4+
"version": "0.4.1",
55
"homepage": "http://www.js-data.io/js-data-http",
66
"repository": {
77
"type": "git",
@@ -18,38 +18,38 @@
1818
}
1919
],
2020
"devDependencies": {
21-
"grunt": "^0.4.5",
22-
"grunt-browserify": "^3.0.0",
23-
"grunt-contrib-clean": "^0.6.0",
24-
"grunt-contrib-concat": "^0.5.0",
25-
"grunt-contrib-copy": "^0.5.0",
26-
"grunt-contrib-jshint": "^0.10.0",
27-
"grunt-contrib-uglify": "^0.5.1",
28-
"grunt-contrib-watch": "^0.6.1",
29-
"grunt-karma": "^0.8.3",
30-
"grunt-karma-coveralls": "^2.5.1",
31-
"karma": "^0.12.23",
32-
"karma-chai": "^0.1.0",
33-
"karma-chrome-launcher": "^0.1.4",
34-
"karma-coverage": "^0.2.6",
35-
"karma-script-launcher": "^0.1.0",
36-
"karma-firefox-launcher": "^0.1.3",
37-
"karma-phantomjs-launcher": "^0.1.4",
38-
"karma-mocha": "^0.1.9",
39-
"karma-sinon": "^1.0.3",
40-
"karma-spec-reporter": "^0.0.13",
41-
"time-grunt": "^1.0.0",
42-
"jit-grunt": "^0.8.0"
21+
"grunt": "0.4.5",
22+
"grunt-browserify": "3.0.1",
23+
"grunt-contrib-clean": "0.6.0",
24+
"grunt-contrib-concat": "0.5.0",
25+
"grunt-contrib-copy": "0.6.0",
26+
"grunt-contrib-jshint": "0.10.0",
27+
"grunt-contrib-uglify": "0.6.0",
28+
"grunt-contrib-watch": "0.6.1",
29+
"grunt-karma": "0.9.0",
30+
"grunt-karma-coveralls": "2.5.2",
31+
"karma": "0.12.23",
32+
"karma-chai": "0.1.0",
33+
"karma-chrome-launcher": "0.1.4",
34+
"karma-coverage": "0.2.6",
35+
"karma-script-launcher": "0.1.0",
36+
"karma-firefox-launcher": "0.1.3",
37+
"karma-phantomjs-launcher": "0.1.4",
38+
"karma-mocha": "0.1.9",
39+
"karma-sinon": "1.0.3",
40+
"karma-spec-reporter": "0.0.13",
41+
"time-grunt": "1.0.0",
42+
"jit-grunt": "0.8.0"
4343
},
4444
"scripts": {
4545
"test": "grunt test"
4646
},
4747
"peerDependencies": {
48-
"js-data": "0.0.1"
48+
"js-data": "~0.4.x"
4949
},
5050
"dependencies": {
51-
"axios": "^0.3.1",
52-
"es6-promise": "^1.0.0",
53-
"mout": "^0.10.0"
51+
"axios": "0.3.1",
52+
"es6-promise": "1.0.0",
53+
"mout": "0.10.0"
5454
}
5555
}

src/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ defaultsPrototype.queryTransform = function (resourceName, params) {
2121

2222
defaultsPrototype.basePath = '';
2323

24+
defaultsPrototype.forceTrailingSlash = '';
25+
2426
defaultsPrototype.httpConfig = {};
2527

2628
defaultsPrototype.log = console ? console.log : function () {
@@ -52,7 +54,10 @@ dsHttpAdapterPrototype.getAllPath = function (resourceConfig, options) {
5254
dsHttpAdapterPrototype.HTTP = function (config) {
5355
var _this = this;
5456
var start = new Date().getTime();
55-
config = deepMixIn(config, this.defaults.httpConfig);
57+
config = deepMixIn(config, _this.defaults.httpConfig);
58+
if (_this.defaults.forceTrailingSlash && config.url[config.url.length] !== '/') {
59+
config.url += '/';
60+
}
5661
return http(config).then(function (data) {
5762
if (_this.defaults.log) {
5863
var args = Array.prototype.slice.call(arguments);

0 commit comments

Comments
 (0)