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

Support case insensitive matching in prefix/suffix operators #6468

Merged

Conversation

benwebber
Copy link
Contributor

Support caseinsensitive/caseinsensitive suffixes in the following filter operators:

  • prefix
  • suffix
  • removeprefix
  • removesuffix

The suffixes have the same behaviour as the match operator.

Closes: #6407


The existing case sensitivity blurb for the match operator works with for these filters as well. Maybe we can extract it as its own tiddler?

@saqimtiaz
Copy link
Member

Thank you @benwebber
Could you please also add some tests for the operators that now have new suffixes? The existing tests for the prefix operator can be found here:
https://github.com/Jermolene/TiddlyWiki5/blob/master/editions/test/tiddlers/tests/test-filters.js#L270

The tests can be run via tiddlywiki editions/test

@benwebber
Copy link
Contributor Author

benwebber commented Feb 18, 2022

Ran into something adding the test cases. What is the expected behaviour of removeprefix and removesuffix if the parameter is the empty string? Currently they act differently.

removeprefix does not filter the input:

ABCDE abcde +[removeprefix[]]
ABCDE abcde

Whereas removesuffix discards all titles:

ABCDE abcde +[removesuffix[]]

Intuitively, I would expect removesuffix to behave like removeprefix.

EDIT: prefix and suffix exhibit the same behaviour.

ABCDE abcde +[prefix[]]
ABCDE abcde

ABCDE abcde +[suffix[]]

@saqimtiaz
Copy link
Member

Ran into something adding the test cases. What is the expected behaviour of removeprefix and removesuffix if the parameter is the empty string? Currently they act differently.

That is almost surely not intentional, however we now have to consider the problem of keeping the code backwards compatible. I am personally tempted to correct the behaviour of removesuffix[] so that it does not filter the list and remove all items when called with an empty string as operand. Thoughts @Jermolene ?

@Jermolene
Copy link
Member

Thanks @benwebber @saqimtiaz

I am personally tempted to correct the behaviour of removesuffix[] so that it does not filter the list and remove all items when called with an empty string as operand. Thoughts @Jermolene ?

I think that makes sense.

@benwebber
Copy link
Contributor Author

Great. suffix has the same behaviour, should we change it too?

@saqimtiaz
Copy link
Member

Great. suffix has the same behaviour, should we change it too?

Yes please.

@benwebber benwebber force-pushed the issue/6407-caseinsensitive-prefix branch from 22c8397 to 933e89e Compare February 21, 2022 17:14
Support `caseinsensitive`/`caseinsensitive` suffixes in the following
filter operators:

  * prefix
  * suffix
  * removeprefix
  * removesuffix

The suffixes have the same behaviour as in the match operator.

Closes: TiddlyWiki#6407
@benwebber benwebber force-pushed the issue/6407-caseinsensitive-prefix branch from 933e89e to 4d1b970 Compare February 21, 2022 17:19
@benwebber benwebber force-pushed the issue/6407-caseinsensitive-prefix branch from 4d1b970 to e22cfa5 Compare February 21, 2022 17:20
@saqimtiaz
Copy link
Member

bump

@Jermolene
Copy link
Member

Great stuff, thanks @benwebber

@Jermolene Jermolene merged commit 95bd694 into TiddlyWiki:master Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[IDEA] caseinsensitive behavior for prefix/suffix operators
3 participants