Sitelet https://github.com/cdimascio/dotenv-java/issues/83
Skip to content

Improvement on filename() method #83

Description

@saiema

When calling Dotenv.configure().filename(F), there is no check if F is an absolute path, leading to always prepending ./, except of course directory() is called with "" as argument.

I don't believe this to be a bug, but this could be improved with a simple check on the filename argument.

Kind regards,

Simon.

Activity

  1. cdimascio commented on Mar 19, 2025

    @cdimascio
    Owner

    @saiema thanks for the ticket. note that filename should not be a file path, but simply a filename. doc

    it is used when the name of the .env is something other than .env, for instance env or my-custom-env-file.ext, etc

    directory (doc) is help Dotenv find the .env file.

    does this help? perhaps some validation to ensure F in filename(F) is not a path may help avoid confusion.

  2. saiema commented on Mar 19, 2025

    @saiema
    Author

    Dear @cdimascio,

    I think I misread the filename method's documentation, maybe I thought that the argument was a path when it was just a name.

    I don't think a validation in method filename is required, null and non-empty validations would be much better than validating that the argument is not a path. I don't see any code dealing with a null or empty filename.

    Kind regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions