Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ TibiaData API written in Golang and deployed in container (version v3 and above)

Documentation of API endpoints can be found on [docs.tibiadata.com](https://docs.tibiadata.com).

The character response's `married_to` field uses regular spaces (`U+0020`) instead
of non-breaking spaces (`U+00A0`) for both HTML and fansite API sources.

## Table of Contents

- [API versions](#api-versions)
Expand Down
2 changes: 1 addition & 1 deletion src/TibiaCharactersCharacter.go
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ func TibiaCharactersCharacterImpl(BoxContentHTML, url string) (CharacterResponse
characterInfo.FormerNames = fansiteData.CharacterGameInformation.FormerNames
}
if fansiteData.CharacterGameInformation.Spouse != nil {
characterInfo.MarriedTo = *fansiteData.CharacterGameInformation.Spouse
characterInfo.MarriedTo = strings.ReplaceAll(*fansiteData.CharacterGameInformation.Spouse, "\u00A0", " ")
}
if fansiteData.CharacterGameInformation.FormerWorld != nil && *fansiteData.CharacterGameInformation.FormerWorld != "" {
characterInfo.FormerWorlds = strings.Split(*fansiteData.CharacterGameInformation.FormerWorld, ", ")
Expand Down
9 changes: 7 additions & 2 deletions src/TibiaCharactersCharacter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func TestFansiteUnixConversions(t *testing.T) {

func TestFansiteCharacterJSONOptionalFields(t *testing.T) {
comment := "first line\r\nsecond line"
spouse := "Married Character"
spouse := "Married\u00A0Character"
formerWorld := "Antica, Premia"
guildName := "Test Guild"
guildRank := "Leader"
Expand Down Expand Up @@ -223,6 +223,7 @@ func TestFansiteCharacterJSONFixtures(t *testing.T) {
}

func TestCharacterTrollefar(t *testing.T) {
var marriedTo [2]string
testCases := []struct {
name string
fixture string
Expand All @@ -243,7 +244,7 @@ func TestCharacterTrollefar(t *testing.T) {
},
}

for _, tc := range testCases {
for i, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
file, err := static.TestFiles.Open(tc.fixture)
if err != nil {
Expand Down Expand Up @@ -279,6 +280,7 @@ func TestCharacterTrollefar(t *testing.T) {
assert.Nil(character.FormerWorlds)
assert.Equal("Thais", character.Residence)
assert.Equal("Mighty troll", character.MarriedTo)
marriedTo[i] = character.MarriedTo
assert.Nil(character.Houses)
assert.Equal("Elysium", character.Guild.GuildName)
assert.Equal("Follower", character.Guild.Rank)
Expand All @@ -290,6 +292,9 @@ func TestCharacterTrollefar(t *testing.T) {
assert.Equal(tc.expectedFirst, information.TibiaURLs[0])
})
}

// HTML uses a non-breaking space; JSON uses a regular space.
assert.Equal(t, marriedTo[0], marriedTo[1])
}

func TestCharacterMightyTroll(t *testing.T) {
Expand Down
Loading