Repository: nushell/nushell
File: crates/nu-command/src/filesystem/start.rs (Rust)

Code before:
        vec!["load", "folder", "directory", "run", "open"]
    }

    fn signature(&self) -> nu_protocol::Signature {
        Signature::build("start")
            .input_output_types(vec![(Type::Nothing, Type::Any)])
            .required("path", SyntaxShape::String, "Path or URL to open.")
            .category(Category::FileSystem)
    }

    fn run(
        &self,
        engine_state: &EngineState,
        stack: &mut Stack,
        call: &Call,
        _input: PipelineData,
    ) -> Result<PipelineData, ShellError> {
        let path = call.req::<Spanned<String>>(engine_state, stack, 0)?;
        let path = Spanned {
            item: nu_utils::strip_ansi_string_unlikely(path.item),
            span: path.span,
        };
        let path_no_whitespace = path
            .item
            .trim_end_matches(|x| matches!(x, '\x09'..='\x0d'))
            .to_string();
        // Load allowed schemes from environment variable
        // Attempt to parse the input as a URL
        if let Ok(url) = url::Url::parse(&path_no_whitespace) {
            open_path(url.as_str(), engine_state, stack, path.span)?;
            return Ok(PipelineData::Empty);
        }
        // If it's not a URL, treat it as a file path
        let cwd = engine_state.cwd(Some(stack))?;
        let path_buf = Path::new(&path_no_whitespace).to_path_buf();
        let full_path = cwd.join(&path_buf);
        // Check if the path exists or if it's a valid file/directory
        if full_path.exists() || path_buf.components().count() == 1 {
            // The path exists or is a single component (might be a new file)
            open_path(full_path, engine_state, stack, path.span)?;
            return Ok(PipelineData::Empty);
        }
        // If neither file nor URL, return an error
        Err(ShellError::GenericError {
            error: format!("Cannot find file or URL: {}", &path.item),
            msg: "".into(),
            span: Some(path.span),
            help: Some("Ensure the path or URL is correct and try again.".into()),
            inner: vec![],
        })
    }

Review comment (suggestion):
```suggestion
            .trim_end_matches(|x| matches!(x, '\x09'..='\x0d'));
```

Code after:
    }

    fn signature(&self) -> nu_protocol::Signature {
        Signature::build("start")
            .input_output_types(vec![(Type::Nothing, Type::Any)])
            .required("path", SyntaxShape::String, "Path or URL to open.")
            .category(Category::FileSystem)
    }

    fn run(
        &self,
        engine_state: &EngineState,
        stack: &mut Stack,
        call: &Call,
        _input: PipelineData,
    ) -> Result<PipelineData, ShellError> {
        let path = call.req::<Spanned<String>>(engine_state, stack, 0)?;
        let path = Spanned {
            item: nu_utils::strip_ansi_string_unlikely(path.item),
            span: path.span,
        };
        let path_no_whitespace = path.item.trim_end_matches(|x| matches!(x, '\x09'..='\x0d'));
        // Attempt to parse the input as a URL
        if let Ok(url) = url::Url::parse(path_no_whitespace) {
            open_path(url.as_str(), engine_state, stack, path.span)?;
            return Ok(PipelineData::Empty);
        }
        // If it's not a URL, treat it as a file path
        let cwd = engine_state.cwd(Some(stack))?;
        let full_path = cwd.join(path_no_whitespace);
        // Check if the path exists or if it's a valid file/directory
        if full_path.exists() {
            open_path(full_path, engine_state, stack, path.span)?;
            return Ok(PipelineData::Empty);
        }
        // If neither file nor URL, return an error
        Err(ShellError::GenericError {
            error: format!("Cannot find file or URL: {}", &path.item),
            msg: "".into(),
            span: Some(path.span),
            help: Some("Ensure the path or URL is correct and try again.".into()),
            inner: vec![],
        })
    }
    fn examples(&self) -> Vec<nu_protocol::Example> {
        vec![
            Example {
                description: "Open a text file with the default text editor",
                example: "start file.txt",
                result: None,
            },