Skip to content

Commit

Permalink
Fix #2967: MathSciNet tab works again
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Jul 13, 2017
1 parent d922e55 commit 55a6857
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,21 @@ public MathSciNetId(String identifier) {

public static Optional<MathSciNetId> parse(String mrNumberRaw) {
// Take everything before whitespace or open bracket, so something like `619693 (82j:58046)` gets parsed correctly
return Optional.of(new MathSciNetId(StringUtil.tokenizeToList(mrNumberRaw, " (").get(0)));
String identifier = StringUtil.tokenizeToList(mrNumberRaw, " (").get(0).trim();
return Optional.of(new MathSciNetId(identifier));
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MathSciNetId that = (MathSciNetId) o;
return Objects.equals(identifier, that.identifier);
}

@Override
public int hashCode() {
return Objects.hash(identifier);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.jabref.model.entry.identifier;

import java.util.Optional;

import org.junit.Test;

import static org.junit.Assert.assertEquals;

public class MathSciNetIdTest {

@Test
public void parseRemovesNewLineCharacterAtEnd() throws Exception {
Optional<MathSciNetId> id = MathSciNetId.parse("3014184\n");
assertEquals(Optional.of(new MathSciNetId("3014184")), id);
}
}

0 comments on commit 55a6857

Please sign in to comment.