Skip to content

Commit

Permalink
handle empty tags attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
psharanda committed Mar 15, 2018
1 parent 1f44138 commit 73db896
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 1 addition & 3 deletions Sources/String+Detection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ extension String {
break
}

guard let value = tagScanner.scanUpTo("\"") else {
break
}
let value = tagScanner.scanUpTo("\"") ?? ""

guard tagScanner.scanString("\"") != nil else {
break
Expand Down
12 changes: 12 additions & 0 deletions Tests/AtributikaTests/AtributikaTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,18 @@ class AtributikaTests: XCTestCase {

XCTAssertEqual(test, reference3)
}

func testTagAttributes() {
let test = "Hello <a class=\"big\" target=\"\" href=\"http://foo.com\">world</a>!"

let (string, tags) = test.detectTags()


XCTAssertEqual(string, "Hello world!")
XCTAssertEqual(tags[0].tag.attributes["class"], "big")
XCTAssertEqual(tags[0].tag.attributes["target"], "")
XCTAssertEqual(tags[0].tag.attributes["href"], "http://foo.com")
}
}


Expand Down

0 comments on commit 73db896

Please sign in to comment.