Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

stripTrailingSlashes not working? #15404

Closed

Description

@davidanaya

Hi

I'm having some problems with the property stripTrailingSlashes in angular $resource.
Maybe I'm missunderstanding what this is aimed to, but I've tried to use it to get rid of '%2F' in my urls with no success.

I've a plunkr to ilustrate what I want to do.

I'm trying to access a json file through a URL and in my plunkr it's actually working, but if I check the network tab in the console I can see the URL for the request is
https://run.plnkr.co/nPEfSPa0Ejn8MXjk/data%2Ffolder/test.json

So, in my real web application this is also happening, but the request is not being processed.
I thought that by using stripTrailingSlashes to false this could be avoided.

My code is here (also in the plunkr link)

angular

.module('appModule', ['ngResource'])
.controller('AppController', ['$resource', function($resource) {
  
  var vm = this;
  
  var reader = $resource(':context' + '/:file.json', {}, {
		query: {method: 'GET', params: {context: '@context', file: '@file'}}
	}, { stripTrailingSlashes: false });
	
	function load(context, file) {
	  console.log('resource in ' + context + '/' + file);
	  reader.query({context:context, file:file}, 
				function(data) {
				  console.log('success');
				  vm.data = data.name;
				}, 
				function(error) { 
				  console.log('error');
				}
			);
	}
	
	load('data/folder', 'test');
}])

Any help on that?

Activity

  1. gkalpak commented on Nov 17, 2016

    @gkalpak
    Member

    stripTrailingSlashes is totally irrelevant (it is about stripping trailing slashes). Your issue is with encoding slashes in parameter values.

    I am not too keen on changing this (mainly due to its security implications). There is some discussion #7940.

    In any case, this is a duplicate of #1388. Follow that threads for updates (but don't hold your breath 😃).

  2. bieniekmateusz commented on May 1, 2018

    @bieniekmateusz

    From the #7940 the relevant part here mentioned by @gkalpak is this:
    $resource('project/:id', {"id": '@id'}, {query: {method: 'GET', isArray: true},}, {encodeSlashes: false})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions