Passed parameter with special characters results in 404


#1

Hello,

I have this in my routes:

{
path: ‘/post/:postid/:posturl/:postdate/:postcaption/’,
template:‘

Hello {{$route.params.postid}} , {{$route.params.posturl}}, {{$route.params.postcaption}}

’,
},
{
path: ‘(.*)’,
url: ‘./pages/404.html’,
},

Can somebody explain to me why my page results in a 404 when there’s a special character in the {{$route.params.postcaption}} output? There are special characters in {{$route.params.posturl}} as well but it displays the passed parameter without issues. Am I missing something?

Thanks! :slight_smile:


#2

hi,
can you share the raw url of both routes


#3

Hello :slight_smile:

Not sure if I understand you correctly, were you asking for the route that contains the perimeters to be passed?

{
path: ‘/me/’,
url: ‘./pages/me.html’,
},

If you were asking for a link, I’m afraid there isn’t. Sorry. Phonegap plugins in the app made it not work properly in browsers. :confused:


#4

ok, and you dont know the link?
can you make an alert with the link and paste de route;

‘/post/:postid/:posturl/:postdate/:postcaption/’
/post/1/somepost/201810515/none

#5

Oooh… I get what you mean now. Hahaha! Sorry about that. :slight_smile:

Here’s one of the links that result in 404:

/post/:postid/:posturl/:postdate/:postcaption/
/post/13/userid_533783103.jpg/2018-05-11 16:34:39/Testing Pls work./

The postcaption parameter is what’s causing the error. As you can see, it’s not different from the others but whenever I remove the period it works as intended. When I leave it as it is, it results in an error.

Thanks for taking time to look into this. :slight_smile:


#6

can you try your route like this:

encodeURI('/post/13/userid_533783103.jpg/2018-05-11 16:34:39/Testing Pls work./')
=>
"/post/13/userid_533783103.jpg/2018-05-11%2016:34:39/Testing%20Pls%20work./"

#7

I did but it didn’t work, unfortunately. Any idea what’s going on with it?


#8

my bad, try now

encodeURIComponent ('/post/13/userid_533783103.jpg/2018-05-11 16:34:39/Testing Pls work./')
->
"%2Fpost%2F13%2Fuserid_533783103.jpg%2F2018-05-11%2016%3A34%3A39%2FTesting%20Pls%20work.%2F"

#9

Sorry, still doesn’t work. I’m thinking if we can replace the period with something like “[period]”, then pass it, then, turn it back into a period then I think we’re set. Although I don’t think it’s impossible to do in routes?


#10

ok, one last try
if this dosnt work, i think that you should replade the dot with another char

encodeURIComponent ('/post/13/userid_533783103.jpg/2018-05-11 16:34:39/Testing Pls work./').replace(/\./g, '%2E');

#11

It didn’t work either. I guess I’ll have to find another way then. Thanks for all your help @pvtallulah. Truly appreciate it! :slight_smile:

If I find another solution I’ll be sure to update this thread.


#12

ok i will test your route problem when i have some time.


#13

@Timidyo.
So i test it and the solution was really simple;

i change this route:

path: '/post/:postid/:posturl/:postdate/:postcaption/',

for this one:

// Note i remove the last slash ---> /
path: '/post/:postid/:posturl/:postdate/:postcaption',

and my link is like this:

// also no slash
<a class="item-content item-link" href="/post/13/userid_533783103.jpg/2018-05-11 16:34:39/Testing Pls work.">

my result on pageInit page.route.params

{
  "postid": "13",
  "posturl": "userid_533783103.jpg",
  "postdate": "2018-05-11 16:34:39",
  "postcaption": "Testing Pls work."
}

give it a try