Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config option to ignore extra paths #2265

Open
sutterseba opened this issue Nov 14, 2024 · 1 comment
Open

Config option to ignore extra paths #2265

sutterseba opened this issue Nov 14, 2024 · 1 comment
Labels
Milestone

Comments

@sutterseba
Copy link

Summary

Currently, there is a config option "Append extra path", which will append extra paths in the URI to the destination, e.g. /example/blah will forward to destination.com/blah.

A similar config option that does not append additional paths to the destination and instead ignores them would be great and should be quite simple to implement.

short.com/example                -> destination.com
short.com/example/blah           -> destination.com
short.com/example/blah/blah/blah -> destination.com

Use case

This would generally allow distinguishing URLs from each other outside the native tracking/tagging solutions. In my case, I have a lot of old URLs with lots of different additional paths (due to how our old URL shortener worked) which would currently all break with Shlink.

@acelaya acelaya added this to the 4.4.0 milestone Nov 24, 2024
@acelaya
Copy link
Member

acelaya commented Nov 24, 2024

Yeah, I think this shouldn't be super hard to do.

As you noted, there's currently a configuration option to tell if the extra path should be appended when redirecting. This option accepts true and false values.

I would probably deprecate this option and replace it with a more flexible one that accepts a set of values that would determine how to match short URLs when an extra path is found:

  • default: Any extra path will result in no short URL matched (404). Equivalent of passing false for current REDIRECT_APPEND_EXTRA_PATH option.
  • append: The extra path is appended before redirecting. Equivalent of passing true for current REDIRECT_APPEND_EXTRA_PATH option.
  • ignore: The new behavior requested here.

The last two options would be handled in ExtraPathRedirectMiddleware, ignoring the $extraPath if the option is configured as ignore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

2 participants