Correct image extension with route filter

dutchbb

Well-known member
When using CDN with caching or other you can use the route filter and also keep the correct extension. This should be picked up as images, you can also add a question mark ? at the end.

At the end of the converted url you get a slash / (.jpg/) but that has no effect on the detection by CDN's or even chrome (removes the / when you check devtools -> sources).

Code:
Find Route  -> Replace With        

attachments/{name:string}-doc.{name:digit} -> attachments/{name:string}.{name:digit}.doc

attachments/{name:string}-docx.{name:digit} -> attachments/{name:string}.{name:digit}.docx

attachments/{name:string}-gif.{name:digit} -> attachments/{name:string}.{name:digit}.gif

attachments/{name:string}-jpe.{name:digit} -> attachments/{name:string}.{name:digit}.jpe

attachments/{name:string}-jpeg.{name:digit} -> attachments/{name:string}.{name:digit}.jpeg

attachments/{name:string}-jpg.{name:digit} -> attachments/{name:string}.{name:digit}.jpg

attachments/{name:string}-mp4.{name:digit} -> attachments/{name:string}.{name:digit}.mp4

attachments/{name:string}-pdf.{name:digit} -> attachments/{name:string}.{name:digit}.pdf

attachments/{name:string}-png.{name:digit} -> attachments/{name:string}.{name:digit}.png

attachments/{name:string}-psd.{name:digit} -> attachments/{name:string}.{name:digit}.psd

attachments/{name:string}-txt.{name:digit} -> attachments/{name:string}.{name:digit}.txt

attachments/{name:string}-xlsx.{name:digit} -> attachments/{name:string}.{name:digit}.xlsx

attachments/{name:string}-zip.{name:digit} -> attachments/{name:string}.{name:digit}.zip
 
Last edited:

dutchbb

Well-known member
Cloudflare, you have to add a rule for attachments. Could also be others that work the same.
 
Top