Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Formatter only escapes first space character in feature Id #127

Closed
simondean opened this issue Jun 22, 2013 · 2 comments
Closed

JSON Formatter only escapes first space character in feature Id #127

simondean opened this issue Jun 22, 2013 · 2 comments

Comments

@simondean
Copy link
Contributor

Hi. There's a bug in the JSON formatter in the way that spaces are escaped in the feature ID. Only the first space in a feature name is escaped with a hyphen.

[{
    "id": "Waiting-10 seconds",
    "name": "Waiting 10 seconds",
    "description": "",
    "line": 1,
    "keyword": "Feature",
    "uri": "C:\\code\\myriad\\myriad-cucumber-js-example\\features\\waiting\\waiting_10_seconds.feature",
    "elements": [{
        "name": "Waiting 10 seconds",
        "id": "Waiting-10 seconds;waiting-10-seconds",
        "line": 4,
        "keyword": "Scenario",
        "description": "",
        "type": "scenario",
        "tags": [{
            "name": "@api",
            "line": 3
        }]
    }]
}]

The bug is in this line of lib/cucumber/listener/json_formatter.js:

currentFeatureId = feature.getName().replace(' ', '-'); // FIXME: wrong abstraction level, this should be encapsulated

Using a regex in the replace would fix it.

currentFeatureId = feature.getName().replace(/ /g, '-'); // FIXME: wrong abstraction level, this should be encapsulated

Do the other ports of cucumber just escape spaces or other characters too?

pimterry added a commit to pimterry/cucumber-js that referenced this issue Dec 8, 2013
@jbpros
Copy link
Member

jbpros commented Dec 11, 2013

Closed by b5bd31a

@jbpros jbpros closed this as completed Dec 11, 2013
@lock
Copy link

lock bot commented Oct 25, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants