sitemule / ILEastic

Embedded application server for ILE on IBM i
Apache License 2.0
58 stars 29 forks source link

Path parameter binding not working if parameter is in middle of URL #89

Closed m1h43l closed 3 years ago

m1h43l commented 4 years ago

il_addRoute(config : %paddr(getProperty) : IL_GET : '^\/api\/mapping\/[^\/]+/{property}$');

with the following URL: http://host:44000/api/mapping/16/value/dummy

results in a parameter binding for property of "value/dummy"

In this case as the path parameter should be the last segment of the URL is should have resulted in not finding any route as this route does not match the URL.

NielsLiisberg commented 4 years ago

1) Don't think you have to escape / 2) I think it is that ^ issues ...

On Thu, Aug 6, 2020 at 9:44 AM m1h43l notifications@github.com wrote:

il_addRoute(config : %paddr(getProperty) : IL_GET : '^\/api\/mapping\/[^\/]+/{property}$');

with the following URL: http://host:44000/api/mapping/16/value/dummy

results in a parameter binding for property of "value/dummy"

In this case as the path parameter should be the last segment of the URL is should have resulted in not finding any route as this route does not match the URL.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/sitemule/ILEastic/issues/89, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVIPHSES3VRHNRIOLCJ6ZLR7JNPPANCNFSM4PWJVCUQ .

m1h43l commented 4 years ago

I think the issue is in this line : https://github.com/sitemule/ILEastic/blob/master/src/api.c#L359

The named parameter is replaced with (.*) but this also includes the forward slash. It seems to work if we exclude the forward slash like this ([^/]+) and we want to have at least one character thus the +.

NielsLiisberg commented 4 years ago

Correct. My implementation is not perfect

fre. 14. aug. 2020 kl. 15.57 skrev m1h43l notifications@github.com:

I think the issue is in this line : https://github.com/sitemule/ILEastic/blob/master/src/api.c#L359

The named parameter is replaced with (.*) but this also includes the forward slash. It seems to work if we exclude the forward slash like this ([^/]+) and we want to have at least one character thus the +.

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/sitemule/ILEastic/issues/89#issuecomment-674061098, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVIPHRV7WD4RCB537QKKL3SAUYCHANCNFSM4PWJVCUQ .

m1h43l commented 3 years ago

Works now. Thanks.