timetracker icon indicating copy to clipboard operation
timetracker copied to clipboard

check for correct path including / at the end

Open SehLax opened this issue 5 years ago • 0 comments

I ran into an error that might be rare but really annoying: on my phone, the app looked fine, but the startTimer function (green arrow button) did not work at all. From debugging, I realized timer.js was calling a wrong ajax URL: /index.php/apps/ajax/start-timer instead of /index.php/apps/timetracker/ajax/start-timer, something which did not happen on my desktop. At the end I realized that when I had pasted the URL of the timetracker app into my browser URL bar, I simply had lost the slash on the end of the URL – I had opened /index.php/apps/timetracker instead of /index.php/apps/timetracker/, which makes the call $.post( "ajax/start-timer" remove the timetracker part of the URL.

Possible Solution 1: It would work using the baseUrl variable that is created some lines before in timer.js plus a slash, but I read in the debugger that it's deprecated? Possible Solution 2: I realized some other apps redirect their URL when opening, usually adding / at the end, maybe this app or Nextcloud itself should also do this?

PS: During debugging, I noticed that if ('Error' in response){ creates an error itself in this case, because response then is an HTML response and not an object. Maybe something like if (response.constructor == Object) { should be added?

SehLax avatar Oct 07 '20 21:10 SehLax