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

Supporting wildcards with * #203

Open
Matthew-Wise opened this issue May 10, 2024 · 2 comments
Open

Supporting wildcards with * #203

Matthew-Wise opened this issue May 10, 2024 · 2 comments
Labels
type/question Further information is requested

Comments

@Matthew-Wise
Copy link

Which version of Skybrud Redirects are you using? (Please write the exact version, example: 4.0.8)

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

10+

Question

Being able to do /* for all children is something we have found useful when doing redirects in code before. Looking at the redirect service, I think swapping it out for a % in the SQL query would be enough, and maybe a UI checkbox for it?

Let me know what you think happy to look at doing a PR for the feature

Thanks
Matt

@Matthew-Wise Matthew-Wise added the type/question Further information is requested label May 10, 2024
@abjerner
Copy link
Member

Hi @Matthew-Wise

I'm not entirely sure this is such a good idea from a technical point - e.g. due to the potential impact in may have on performance, and the extra complexity it will add to the package.

So instead of creating the PR right away, perhaps let's continue the discussion here first. For instance, I'd like to see the SQL for looking up wildcard redirects. I don't think it will be a as simple as replacing a * with a %.

@Matthew-Wise
Copy link
Author

Been thinking about this more as well and your right.

I think we could solve this by having a "include descendants" options in the UI which maps to a bool in SQL.

We could then split the path into segments and query for the full path or the split paths that Include descendants. order by url length so you get the deepest match

------------------ A very rough SQL example (this schema was taken for a v8 project for speed) ------------------

begin tran

declare @SkybrudRedirects TABLE (
[Id] [int] IDENTITY(1,1) NOT NULL,
[Key] [uniqueidentifier] NOT NULL,
[RootId] [int] NOT NULL,
[RootKey] [uniqueidentifier] NOT NULL,
[Url] nvarchar NOT NULL,
[QueryString] nvarchar NOT NULL,
[DestinationType] nvarchar NOT NULL,
[DestinationId] [int] NOT NULL,
[DestinationKey] [uniqueidentifier] NOT NULL,
[DestinationUrl] nvarchar NOT NULL,
[Created] [datetime] NOT NULL,
[Updated] [datetime] NOT NULL,
[IsPermanent] [bit] NOT NULL,
[ForwardQueryString] [bit] NOT NULL,
[DestinationQuery] nvarchar NOT NULL,
[DestinationFragment] nvarchar NOT NULL,
[IncludeDescedents] [bit] NOT NULL
)

insert into @SkybrudRedirects values (NEWID(), 0,NEWID(), '/example','','content',1000,NEWID(),'/', GETDATE(),GETDATE(),1,1,'','',1)

insert into @SkybrudRedirects values (NEWID(), 0,NEWID(), '/example/unquie/result','','content',1000,NEWID(),'/', GETDATE(),GETDATE(),1,1,'','',0)

-- Requested path /example/global

select * from @SkybrudRedirects where [url] = '/example/global' or ([url] = '/example' and IncludeDescedents = 1)

-- Requested path /example/unquie/result

select * from @SkybrudRedirects where [url] = '/example/unquie/result'
or ([url] = '/example/unquie/' and IncludeDescedents = 1)
or ([url] = '/example' and IncludeDescedents = 1)
order by IncludeDescedents, len([Url]) desc

rollback tran

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants