Strip quotes from .env values that have a trailing comment

Open Beginner friendly
#3 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
90/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
javascript, node.js
Domain
backend

Research direction

Read server/env.mjs:13-24 and the .env parsing test in test/core.test.mjs:104-106. Run npm test to see the current behavior, then add the two quoted values with trailing comments to the existing test. Done means both values parse without their quotes and npm test passes.

Written by the indexing model from the issue text.

Description

bug good first issue tests

parseEnv() only removes surrounding quotes when the whole value both starts and ends with a quote. A quoted value followed by an inline comment, which is the style .env.example itself uses, keeps its quotes:

parseEnv('A="abc" # note\nB=\'x y\'  # c')
// → { A: '"abc"', B: "'x y'" }      expected { A: 'abc', B: 'x y' }

The value starts with " but ends with e, so it falls through to the comment-stripping branch. That branch removes # note and leaves the quotes. Someone who writes OPENAI_API_KEY="sk-…" # work account sends the literal quotes in the Authorization header and gets a 401 "check the API key".

Task: when the value opens with a quote, take everything up to the matching closing quote and ignore the rest of the line. Add both cases above to the existing .env parsing test.

Where: server/env.mjs:13-24 (parseEnv), test at test/core.test.mjs:104-106.

Done when: parseEnv('A="abc" # note\nB=\'x y\' # c') returns { A: 'abc', B: 'x y' }, both cases are in the .env parsing test, and npm test passes.


Getting started: Node 22, no npm install needed: git clone, then npm test and npm run check. Comment here to claim it. Questions → Discord.

Dominant language
JavaScript
Stars
42
Forks
6
Avg merge
12h 31m
Merged PRs (30d)
3

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from blixvip/GenMotion

All issues in blixvip/GenMotion

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.