Skip to content

Line substring is redundant when spaces are present #2

@Cubified

Description

@Cubified

link = link.substring(0, link.indexOf(" ", openParen));

The value stored in link from the first time substring() is called gets overwritten by the second time substring() is called, making the first call to the method redundant.

To fix, add an else block around the second substring(), or add a trim() to link.

A test that breaks is:

[hello](world.com)    <-- There are spaces
1) testGetLinks_testFile10(MarkdownParseTest)
java.lang.AssertionError: Validate MarkdownParse on test-file10.md expected:<[world.com]> but was:<[]>
        at org.junit.Assert.fail(Assert.java:89)
        at org.junit.Assert.failNotEquals(Assert.java:835)
        at org.junit.Assert.assertEquals(Assert.java:120)
        at MarkdownParseTest.testGetLinks_testFile10(MarkdownParseTest.java:183)

FAILURES!!!
Tests run: 22,  Failures: 1

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