Search code examples
luafluent-bit

Rewrite Url to hide the information using lua regex


I am using lua plugin for fluentbit to hide my url.

original content
https://www.example.com/file/1234

marked content
https://www.example.com/xxxxxxx

What would be the proper regex to update the url string?


Solution

  • You seem to want to delete everything after the first / after //. The code below fits this description:

    s="https://www.example.com/file/1234"
    print((s:gsub("(.-//.-/)(.*)","%1xxxxxxx")))