From c8e2fab4c3b0428c66081c4355d8a0f214d7d2ac Mon Sep 17 00:00:00 2001 From: Artem Chepurnoy Date: Sun, 7 Jan 2024 22:42:20 +0200 Subject: [PATCH] Add {url:parameter:} placeholder for extracting query parameters --- .../service/placeholder/impl/UrlPlaceholder.kt | 12 ++++++++++++ wiki/PLACEHOLDERS.md | 1 + 2 files changed, 13 insertions(+) diff --git a/common/src/commonMain/kotlin/com/artemchep/keyguard/common/service/placeholder/impl/UrlPlaceholder.kt b/common/src/commonMain/kotlin/com/artemchep/keyguard/common/service/placeholder/impl/UrlPlaceholder.kt index 3cb3d69..aa1a35f 100644 --- a/common/src/commonMain/kotlin/com/artemchep/keyguard/common/service/placeholder/impl/UrlPlaceholder.kt +++ b/common/src/commonMain/kotlin/com/artemchep/keyguard/common/service/placeholder/impl/UrlPlaceholder.kt @@ -55,6 +55,18 @@ class UrlPlaceholder( .let(::io) } + key.startsWith("url:parameter:", ignoreCase = true) -> { + val name = key.substringAfter("url:parameter:") + uuu.parameters[name] + .let(::io) + } + + key.startsWith("base:parameter:", ignoreCase = true) -> { + val name = key.substringAfter("base:parameter:") + uuu.parameters[name] + .let(::io) + } + key.equals("url:userinfo", ignoreCase = true) || key.equals("base:userinfo", ignoreCase = true) -> { val user = uuu.user.orEmpty() diff --git a/wiki/PLACEHOLDERS.md b/wiki/PLACEHOLDERS.md index 71a02fd..a335577 100644 --- a/wiki/PLACEHOLDERS.md +++ b/wiki/PLACEHOLDERS.md @@ -65,6 +65,7 @@ Note: `{base}` supports exactly the same parts as `{url}` and is identical to it | `url:userinfo` | User information: `user:pw` | | `url:username` | Username: `user` | | `url:password` | Password: `pw` | +| `url:parameter:q` | Query parameter with a name `q`: `e` | #### Text transformation