kodi-plugin-routing icon indicating copy to clipboard operation
kodi-plugin-routing copied to clipboard

Stripping of trailing slashes breaks stuff

Open michaelarnauts opened this issue 5 years ago • 12 comments

Related to #22 and #12

It seems the recent changes in routing regarding the stripping of slashes broke a few things. I also learned that Kodi doesn't like urls without a trailing slash when they point to a directory listing. See https://github.com/xbmc/xbmc/issues/16516#issuecomment-529508845 Stripping them seems like a bad idea then. They won't work when bookmarked since the last part gets stripped of if it doesn't end with a slash.

IMO, this should be the right behavior then:

  • @plugin.route('/tvshows/category/<category>/'): plugin.url_for() should include the slash
  • @plugin.route('/tvshows/category/<category>'): plugin.url_for() should not include the slash
  • a route to /tvshows/category/ should end up on the function with the @plugin.route('/tvshows/category/<category>/') decorator
  • a route to /tvshows/category should end up on the function with the @plugin.route('/tvshows/category/<category>') decorator

I guess this was the behaviour of 0.2.0.

The one thing that could be added is that:

  • a route to /tvshows/category could also end up on the function with the @plugin.route('/tvshows/category/<category>/') decorator
  • a route to /tvshows/category/ should also end up on the function with the @plugin.route('/tvshows/category/<category>') decorator

@tamland and @dagwieers what do you think?

michaelarnauts avatar Sep 09 '19 15:09 michaelarnauts

With the current behavior:

  • @plugin.route('/tvshows/category/<category>/'): plugin.url_for() doesn't include the slash anymore

This breaks bookmarking.

michaelarnauts avatar Sep 09 '19 15:09 michaelarnauts

@michaelarnauts That was exactly what I intended with #12, the flexibility ought to be there during matching (only).

That said xbmc/xbmc#16516 is a bug, and should be fixed as one.

dagwieers avatar Sep 09 '19 15:09 dagwieers

I was about to post this. I don't update Kodi very often, since doing so always breaks my stuff, and waiting for a bug fix in Kodi core can be like waiting for Half-Life 3, anyway.

da3dsoul avatar Sep 10 '19 07:09 da3dsoul

What's the 'stuff' and the 'things' that broke, exactly? Tested with one of my own plugins and couldn't find any problems with favorites..

tamland avatar Sep 15 '19 14:09 tamland

Check the 2nd comment. If you add a folder to your bookmarks, it will not work without a trailing slash, but the new routing version strips all trailing slashes.

michaelarnauts avatar Sep 15 '19 15:09 michaelarnauts

By bookmarks you mean favorites? Adding folders works fine here..

tamland avatar Sep 15 '19 15:09 tamland

Sorry, I indeed mean favourites. If you have an addon with a path that ends in a number, it will not work. The route gets generated without a trailing slash now, and those don't work in Kodi when used as a favorite or in activatewindow.

michaelarnauts avatar Sep 15 '19 15:09 michaelarnauts

Check https://github.com/xbmc/xbmc/issues/16516#issuecomment-529508845 the issue is explained there.

michaelarnauts avatar Sep 15 '19 15:09 michaelarnauts

VRT NU add-on is also hit by this when using a path identifier.( @plugin.route('/url/<path:url>'))

Stripping of a trailing slash means changing the variable in this case. This should never have happened!

It is completely ridiculous that I have to add the trailing slash again in my code after the routing plugin has just removed the trailing slash.

mediaminister avatar Oct 06 '19 19:10 mediaminister

Personally, I just think it was a bad idea. As far as URLs go in general, '/stop' != '/stop/'

da3dsoul avatar Oct 07 '19 03:10 da3dsoul

@da3dsoul For web-servers, /stop matches /stop/, if /stop (the file entry) was not found. And this is how I wanted to see it implemented: https://github.com/tamland/kodi-plugin-routing/pull/22#issuecomment-529105998

So stripping the slashes always is IMO wrong behavior.

dagwieers avatar Oct 07 '19 11:10 dagwieers

Indeed. That is hopefully going to fix things

da3dsoul avatar Oct 07 '19 11:10 da3dsoul