mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-16 14:27:01 +00:00
aliases: Drop characters when parsing, and support suffix-specific aliases
Today, when a user sets an alias with drop characters and/or suffixes, those go unused, since we always "clean" addresses before alias resolution. This results in unexpected and surprising behaviour, and it's not properly documented either. This patch resolves this unexpected behaviour as follows: - Drop characters are ignored, both at parsing time and at lookup time. - Lookups are done including the suffixes first, and if that results in no matches, they are retried without suffixes. This results in aliases working more intuitively for the most common use cases: of users wanting to have different aliases for specific suffixes, and not having to care for drop characters. Hooks can be used to get different behaviour if needed, since the first lookup is done with the address as-is. Thanks to znerol@ (lo+github@znerol.ch) for reporting this, and the discussion on how to fix it, in https://github.com/albertito/chasquid/issues/41.
This commit is contained in:
@@ -76,6 +76,57 @@ pepe: jose
|
||||
*: pepe, rose@backgarden
|
||||
```
|
||||
|
||||
### Overrides
|
||||
|
||||
If the same left-side address appears more than once, the last one will take
|
||||
precedence.
|
||||
|
||||
For example, in this case, the result is that `pepe` is aliased to `jose`, the
|
||||
first line is effectively ignored.
|
||||
|
||||
```
|
||||
pepe: juan
|
||||
pepe: jose
|
||||
```
|
||||
|
||||
### Drop characters and suffix separators
|
||||
|
||||
When parsing aliases files, drop characters will be ignored. Suffix separators
|
||||
are kept as-is.
|
||||
|
||||
When doing lookups, drop characters will also be ignored. If the address has a
|
||||
suffix, the lookup will include it; if there is no match, it will try again
|
||||
without the suffix.
|
||||
|
||||
In practice, this means that if the aliases file contains:
|
||||
|
||||
```
|
||||
juana.perez: juana
|
||||
juana.perez+fruta: fruta
|
||||
```
|
||||
|
||||
Then (assuming the default drop characters and suffix separators), these are
|
||||
the results:
|
||||
|
||||
```
|
||||
juana.perez -> juana
|
||||
juanaperez -> juana
|
||||
ju.ana.pe.rez -> juana
|
||||
|
||||
juana.perez+abc -> juana
|
||||
juanaperez+abc -> juana
|
||||
|
||||
juana.perez+fruta -> fruta
|
||||
juanaperez+fruta -> fruta
|
||||
```
|
||||
|
||||
This allows addresses with suffixes to have specific aliases, without having
|
||||
to worry about drop characters, which is the most common use case.
|
||||
|
||||
If different semantics are needed, they can be implemented using the
|
||||
[hook](#hooks).
|
||||
|
||||
|
||||
## Processing
|
||||
|
||||
Aliases files are read upon start-up and refreshed every 30 seconds, so
|
||||
|
||||
Reference in New Issue
Block a user