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
@davidanaya

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?

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