From ffc4c8a6eec0bc5ad88d2aa1e76e110d3934aceb Mon Sep 17 00:00:00 2001 From: PDTeamX <8293321+ehsandeep@users.noreply.github.com> Date: Sat, 6 Dec 2025 19:37:56 +0530 Subject: [PATCH] feat: update -ldp option to show default ports in CLI output - Modified URL formatting in runner.go to respect LeaveDefaultPorts option - Fixed AddURLDefaultPort function to actually add default ports (80/443) - When -ldp is used, CLI output now shows https://example.com:443 instead of https://example.com - Maintains backward compatibility - default behavior unchanged Fixes CLI output inconsistency where -ldp flag only affected Host headers but not the displayed URL in console output. --- common/stringz/stringz.go | 8 ++++++++ runner/runner.go | 6 +++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/common/stringz/stringz.go b/common/stringz/stringz.go index 6cc889ce6..5033e1cb0 100644 --- a/common/stringz/stringz.go +++ b/common/stringz/stringz.go @@ -83,6 +83,14 @@ func AddURLDefaultPort(rawURL string) string { if err != nil { return rawURL } + // Force default port to be added if not present + if u.Port() == "" { + if u.Scheme == urlutil.HTTP { + u.UpdatePort("80") + } else if u.Scheme == urlutil.HTTPS { + u.UpdatePort("443") + } + } return u.String() } diff --git a/runner/runner.go b/runner/runner.go index 2035199aa..15dbb627a 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -1723,7 +1723,11 @@ retry: } builder := &strings.Builder{} - builder.WriteString(stringz.RemoveURLDefaultPort(fullURL)) + if scanopts.LeaveDefaultPorts { + builder.WriteString(stringz.AddURLDefaultPort(fullURL)) + } else { + builder.WriteString(stringz.RemoveURLDefaultPort(fullURL)) + } if r.options.Probe { builder.WriteString(" [")