URL normaization, removing dot segments

Has anyone added some VCL logic for normalizing dot-segments according to RFC3986in url paths? Would you be willing to share your insights or any relevant code snippets?

I have found some implementation of dot segment removal in PHP here.
And in the VCL, regsub is the VCL function that needs to be used to achieve a similar thing.
For the above PHP code’s case A, B:
We can get it done in VCL like

# case A
regsub(var.path, "^(../|./)", "");

# case B
regsub(var.path, "^(/./|/.)", "/");

Here is the fiddle that you can test around.

3 Likes