From 36c0e50c2326795658f8406d4e7a31af25253fac Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 25 Apr 2013 23:12:11 -0700 Subject: [PATCH] updated rest routing to only match numeric IDs. eg. Match: api/series/12 No Match: api/series/abc --- NzbDrone.Api/REST/RestModule.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/NzbDrone.Api/REST/RestModule.cs b/NzbDrone.Api/REST/RestModule.cs index 15747d1bd..817ff559b 100644 --- a/NzbDrone.Api/REST/RestModule.cs +++ b/NzbDrone.Api/REST/RestModule.cs @@ -11,7 +11,7 @@ namespace NzbDrone.Api.REST where TResource : RestResource, new() { private const string ROOT_ROUTE = "/"; - private const string ID_ROUTE = "/{id}"; + private const string ID_ROUTE = @"/(?[\d]{1,7})"; private Action _deleteResource; private Func _getResourceById; @@ -55,10 +55,16 @@ namespace NzbDrone.Api.REST { _getResourceById = value; Get[ID_ROUTE] = options => - { - var resource = GetResourceById((int)options.Id); - return resource.AsResponse(); - }; + { + int id; + if (!Int32.TryParse(options.Id, out id)) + { + throw new NotImplementedException(); + } + + var resource = GetResourceById((int)options.Id); + return resource.AsResponse(); + }; } }