Skip to content

Instantly share code, notes, and snippets.

@scmx
Created January 13, 2015 10:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scmx/9e11c6a038e155af4f93 to your computer and use it in GitHub Desktop.
Save scmx/9e11c6a038e155af4f93 to your computer and use it in GitHub Desktop.
How a tiny typo in an angular service that got unnoticed, could become a bug several months later

How a tiny typo in an angular service that got unnoticed, could become a bug several months later

# Typo done in august
.factory("Subtask", function($resource) {
-   return $resource("/tasks/:task_id/subtasks/:id", {task_id: "@task_id", id: "@id"});
+   return $resource("tasks/:task_id/subtasks/:id", {task_id: "@task_id", id: "@id"});
  }]);

But, it worked just fine.

But this week, we started using html5Mode for our routes, which means our routing changed from /#/something/else to /something/else. And because of that, the request made by the service changed a little bit.

- POST /tasks/123/subtasks                (201 Created)
+ POST /something/else/tasks/123/subtasks (404 Not found)

So since the request was always made when the url was / before, the relative url was the same as an absolute one. But with html5Mode, the url when doing the request became /something/else, so that's why it became a 404.

;)

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