Skip to content

Commit 907891f

Browse files
Fix the regular expression and unit test
1 parent 7e2ee15 commit 907891f

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

OpenGraph/OpenGraphParser.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ extension OpenGraphParser {
2424
options: []
2525
)
2626
let contentRegexp = try! NSRegularExpression(
27-
pattern: "\\scontent=(?:\"|\')(.*?)(?:\"|\')",
27+
pattern: "\\scontent=(?:\"|\')(.*?)(?:\"|\')(?:\\s|>)",
2828
options: []
2929
)
3030

Tests/OpenGraphTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class OpenGraphTests: XCTestCase {
4040
}
4141

4242
waitForExpectations(timeout: 10) { _ in
43-
XCTAssert(og[.title] == " < example.com title > ")
43+
XCTAssert(og[.title] == " < It's example.com title > ")
4444
XCTAssert(og[.type] == "website")
4545
XCTAssert(og[.url] == "https://www.example.com")
4646
XCTAssert(og[.image] == "https://www.example.com/images/example.png")
@@ -64,7 +64,7 @@ class OpenGraphTests: XCTestCase {
6464
}
6565

6666
waitForExpectations(timeout: 10) { _ in
67-
XCTAssert(og[.title] == " < example.com title > ")
67+
XCTAssert(og[.title] == " < It's example.com title > ")
6868
XCTAssert(og[.type] == "website")
6969
XCTAssert(og[.url] == "https://www.example.com")
7070
XCTAssert(og[.image] == "https://www.example.com/images/example.png")

Tests/ogp.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<html>
22
<head>
33
<meta charset='utf-8'>
4-
<meta property="og:title" content=" < example.com title > "><meta property="og:type" content="website" />
4+
<meta property="og:title" content=" < It's example.com title > "><meta property="og:type" content="website" />
55
<meta property="og:url" content="https://www.example.com" />
66

77
<!-- og property that has an other attributes. -->

0 commit comments

Comments
 (0)