Skip to content

Commit

Permalink
Remove trailing slashes from appropriate URLs
Browse files Browse the repository at this point in the history
  • Loading branch information
ClickerMonkey committed Dec 7, 2015
1 parent 7522749 commit 4ef86b6
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neurosync-jquery",
"version": "1.0.5",
"version": "1.1.1",
"homepage": "https://github.com/ClickerMonkey/neurosync-jquery",
"authors": [
"Philip Diffenderfer <pdiffenderfer@gmail.com>"
Expand Down
13 changes: 9 additions & 4 deletions build/neurosync-jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
Neuro.rest = function(database)
{

function removeTrailingSlash(x)
{
return x.charAt(x.length - 1) === '/' ? x.substring(0, x.length - 1) : x;
}

function execute( method, data, url, success, failure, offlineValue )
{
Neuro.debug( Neuro.Debugs.REST, this, method, url, data );
Expand Down Expand Up @@ -46,19 +51,19 @@
},
get: function( model, success, failure )
{
execute( 'GET', undefined, database.api + model.$key(), success, failure );
execute( 'GET', undefined, removeTrailingSlash( database.api + model.$key() ), success, failure );
},
create: function( model, encoded, success, failure )
{
execute( 'POST', encoded, database.api, success, failure, {} );
execute( 'POST', encoded, removeTrailingSlash( database.api ), success, failure, {} );
},
update: function( model, encoded, success, failure )
{
execute( 'PUT', encoded, database.api + model.$key(), success, failure, {} );
execute( 'PUT', encoded, removeTrailingSlash( database.api + model.$key() ), success, failure, {} );
},
remove: function( model, success, failure )
{
execute( 'DELETE', undefined, database.api + model.$key(), success, failure, {} );
execute( 'DELETE', undefined, removeTrailingSlash( database.api + model.$key() ), success, failure, {} );
},
query: function( query, success, failure )
{
Expand Down
2 changes: 1 addition & 1 deletion build/neurosync-jquery.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/neurosync-jquery.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "neurosync-jquery",
"version": "1.0.5",
"version": "1.1.1",
"description": "A neurosync binding to jquery - implementing Neuro.rest",
"author": "Philip Diffenderfer",
"license": "MIT",
Expand Down
13 changes: 9 additions & 4 deletions src/neurosync-jquery.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
Neuro.rest = function(database)
{

function removeTrailingSlash(x)
{
return x.charAt(x.length - 1) === '/' ? x.substring(0, x.length - 1) : x;
}

function execute( method, data, url, success, failure, offlineValue )
{
Neuro.debug( Neuro.Debugs.REST, this, method, url, data );
Expand Down Expand Up @@ -46,19 +51,19 @@
},
get: function( model, success, failure )
{
execute( 'GET', undefined, database.api + model.$key(), success, failure );
execute( 'GET', undefined, removeTrailingSlash( database.api + model.$key() ), success, failure );
},
create: function( model, encoded, success, failure )
{
execute( 'POST', encoded, database.api, success, failure, {} );
execute( 'POST', encoded, removeTrailingSlash( database.api ), success, failure, {} );
},
update: function( model, encoded, success, failure )
{
execute( 'PUT', encoded, database.api + model.$key(), success, failure, {} );
execute( 'PUT', encoded, removeTrailingSlash( database.api + model.$key() ), success, failure, {} );
},
remove: function( model, success, failure )
{
execute( 'DELETE', undefined, database.api + model.$key(), success, failure, {} );
execute( 'DELETE', undefined, removeTrailingSlash( database.api + model.$key() ), success, failure, {} );
},
query: function( query, success, failure )
{
Expand Down

0 comments on commit 4ef86b6

Please sign in to comment.