Skip to content
This repository has been archived by the owner on Oct 13, 2020. It is now read-only.

Not working in Firefox. #3

Open
zheli opened this issue Jul 3, 2014 · 3 comments
Open

Not working in Firefox. #3

zheli opened this issue Jul 3, 2014 · 3 comments

Comments

@zheli
Copy link

zheli commented Jul 3, 2014

The demo is not working in Firefox because of this issue: angular/angular.js#992.

A guy on stackoverflow suggested using $http instead.
http://stackoverflow.com/questions/17312683/angular-save-method-fire-a-post-request-with-wrong-url

@zheli
Copy link
Author

zheli commented Jul 3, 2014

I used the solution mentioned in the github issue as a workaround and it works!

angular.module('ngResource').config([
    '$provide', '$httpProvider',
    function($provide, $httpProvider) {
        $provide.decorator('$resource', function($delegate) {
            return function() {
                if (arguments.length > 0) {  // URL
                    arguments[0] = arguments[0].replace(/\/$/, '\\/');
                }

                if (arguments.length > 2) {  // Actions
                    angular.forEach(arguments[2], function(action) {
                        if (action && action.url) {
                            action.url = action.url.replace(/\/$/, '\\/');
                        }
                    });
                }

                return $delegate.apply($delegate, arguments);
            };
        });

        $provide.factory('resourceEnforceSlashInterceptor', function() {
            return {
                request: function(config) {
                    config.url = config.url.replace(/[\/\\]+$/, '/');
                    return config;
                }
            };
        });

        $httpProvider.interceptors.push('resourceEnforceSlashInterceptor');
    }
]);

@richtier
Copy link
Owner

hi, sorry took long time to respond. Please make a pull request with your fix and I will merge it.

@zheli
Copy link
Author

zheli commented Aug 26, 2014

Sure. I will do that:)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants