API routes generate invalid development output

DragonByte Tech

Well-known member
Affected version
2.2.8pl1
Defining the following two routes:

#1
1641315947134.webp

#2
1641315973396.webp

Will both write to api_dbtech-ecommerce_categories_.json.

Suggested solution:
In /src/XF/DevelopmentOutput/Route.php find:
PHP:
        $subNameFile = preg_replace('#[^a-z0-9_-]#i', '-', $subName);

Replace with:
Code:
        $subNameFile = preg_replace('#/$#i', '_', $subName);
        $subNameFile = preg_replace('#[^a-z0-9_-]#i', '-', $subNameFile);

This will cause #1 to write to api_dbtech-ecommerce_categories_.json and #2 to write to api_dbtech-ecommerce_categories-.json, preserving the uniqueness of these routes.
 
Top Bottom