Home / Function/ split_pattern() — tailwindcss Function Reference

split_pattern() — tailwindcss Function Reference

Architecture documentation for the split_pattern() function in glob.rs from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  24c188fc_16f0_5618_de58_f7c31037d124["split_pattern()"]
  d6210432_49e5_7bfc_e9c4_6cebc740bb16["glob.rs"]
  24c188fc_16f0_5618_de58_f7c31037d124 -->|defined in| d6210432_49e5_7bfc_e9c4_6cebc740bb16
  5cbcc657_1c9c_94fa_f9bc_7a654ab63a89["hoist_static_glob_parts()"]
  5cbcc657_1c9c_94fa_f9bc_7a654ab63a89 -->|calls| 24c188fc_16f0_5618_de58_f7c31037d124
  style 24c188fc_16f0_5618_de58_f7c31037d124 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

crates/oxide/src/glob.rs lines 157–187

pub fn split_pattern(pattern: &str) -> (Option<String>, Option<String>) {
    // No dynamic parts, so we can just return the input as-is.
    if !pattern.contains('*') {
        return (Some(pattern.to_owned()), None);
    }

    let mut last_slash_position = None;

    for (i, c) in pattern.char_indices() {
        if c == '/' {
            last_slash_position = Some(i);
        }

        if c == '*' || c == '!' {
            break;
        }
    }

    // Very first character is a `*`, therefore there is no static part, only a dynamic part.
    let Some(last_slash_position) = last_slash_position else {
        return (None, Some(pattern.to_owned()));
    };

    let static_part = pattern[..last_slash_position].to_owned();
    let dynamic_part = pattern[last_slash_position + 1..].to_owned();

    let static_part = (!static_part.is_empty()).then_some(static_part);
    let dynamic_part = (!dynamic_part.is_empty()).then_some(dynamic_part);

    (static_part, dynamic_part)
}

Domain

Subdomains

Frequently Asked Questions

What does split_pattern() do?
split_pattern() is a function in the tailwindcss codebase, defined in crates/oxide/src/glob.rs.
Where is split_pattern() defined?
split_pattern() is defined in crates/oxide/src/glob.rs at line 157.
What calls split_pattern()?
split_pattern() is called by 1 function(s): hoist_static_glob_parts.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free