Ends With
Checks if a string value ends with a specified suffix.
Overview
The ends_with condition evaluates whether a field's string value ends with a specified suffix. This is useful for matching file extensions, domain suffixes, ID patterns, and other cases where the ending of a string is significant.
Use Cases
- File Type Routing: Route based on file extensions (.json, .csv, .log)
- Domain Matching: Match email domains or URL suffixes
- ID Pattern Matching: Route based on ID suffixes or version numbers
- Path-Based Routing: Match URL paths or file paths by suffix
Configuration
| Setting | Type | Required | Description |
|---|---|---|---|
key | string | Yes | The field path to check. Supports dot notation for nested fields. Use * to check all keys. |
value | string | Yes | The suffix to check for. |
case_insensitive | boolean | No | If true, performs case-insensitive comparison. |
not | boolean | No | If true, inverts the condition (matches if value does NOT end with suffix). |
Examples
File Extension Check
Route based on file extension:
Code
Matches:
Code
Does not match:
Code
Email Domain Check
Match emails from specific domains:
Code
Matches:
Code
URL Path Matching
Route API requests by path suffix:
Code
Matches:
Code
Version Suffix Check
Match version strings:
Code
Matches:
Code
Does not match:
Code
Exclusion Check
Match files that are NOT backups:
Code
Matches:
Code
Does not match:
Code
Nested Field Check
Check suffix in nested fields:
Code
Matches:
Code
Common Patterns
Route by File Type
Separate different file types:
Code
Internal vs External Emails
Route based on email domain:
Code
API Endpoint Routing
Route different API endpoints:
Code
Exclude Temporary Files
Filter out temporary and backup files:
Code
Best Practices
-
Include delimiters: When matching extensions, include the dot (
.jsonnotjson) to avoid false matches. -
Use
case_insensitivefor file extensions: File systems may have mixed case extensions. -
Combine with
starts_with: For matching both prefix and suffix patterns. -
Consider URL encoding: URL paths may have encoded characters.
-
Handle trailing characters: Watch for trailing slashes, spaces, or newlines in data.
Type Handling
- Strings: Direct suffix comparison
- Numbers: Converted to strings first (e.g.,
123ends with"3") - Booleans: Converted to "true" or "false" strings
- Arrays/Objects: Not supported for direct comparison
- Missing fields: Returns
false(ortrueifnotis set)
Limitations
- Simple suffix matching only (no patterns or wildcards)
- Single suffix per condition (use
orfor multiple suffixes) - No support for matching multiple suffixes in one condition
Troubleshooting
Not matching expected values:
- Check for trailing whitespace or special characters
- Verify case sensitivity settings
- Ensure the full suffix is specified (e.g.,
.jsonnotjson)
Unexpected matches:
- The suffix might be shorter than intended
- Check for similar suffixes (
.jsmatches both.jsand.mjsfiles)
Case sensitivity issues:
- Enable
case_insensitivefor user-generated content - File extensions may vary in case across systems