Browse Source

Fix wm verification for special case

master
Jan-Lukas Else 2 weeks ago
parent
commit
40a5ceb2c2
  1. 377
      testdata/colin.html
  2. 11
      webmentionVerification.go
  3. 43
      webmentionVerification_test.go

377
testdata/colin.html

@ -0,0 +1,377 @@
<!DOCTYPE html>
<html lang="en-GB">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="theme-color" content="#eeeeee">
<title>Colin Walker - Nov 14, 2021</title>
<meta name="description" content="Writing, blogging, life, tech and mental health with a philosophical/psychological slant">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link defer rel="stylesheet" href="/bigfoot/bigfoot-bottom.css" type="text/css" media="all">
<link defer rel="stylesheet" href="/style.css" type="text/css" media="all">
<link rel="webmention" href="https://colinwalker.blog/endpoint.php"/>
<link rel="http://webmention.org/" href="https://colinwalker.blog/endpoint.php"/>
<link rel="home alternate" type="application/rss+xml" title="Colin Walker :: Daily Feed" href="https://colinwalker.blog/dailyfeed.rss" />
<link rel="alternate" type="application/rss+xml" title="Colin Walker :: Live Feed" href="https://colinwalker.blog/livefeed.rss" />
<link rel="canonical" href="https://colinwalker.blog">
<link rel="me" href="mailto:colin@colinwalker.blog" />
<link rel="me" href="https://micro.blog/colinwalker" />
<script type="text/javascript" src="/script.js"></script>
</head>
<body>
<div id="streak" class="blogin"><a accesskey="l" style="text-decoration: none;" href="/login/?return=blog">(b)log-<picture style="width: 7px; position: relative; top: 1.5px;" class="insertimg"><source srcset="/images/blogin_dark.png" media="(prefers-color-scheme: dark)"><img alt="insert image" style="width: 7px; position: relative; top: 1.5px;" id="insertimg" class="insertimg" src="/images/blogin_light.png" /></picture>n</a></div>
<div id="page" class="hfeed h-feed site">
<header id="masthead" class="site-header">
<div class="site-branding">
<h1 class="site-title">
<a href="https://colinwalker.blog" rel="home">
<span class="p-name">Colin Walker</span>
</a>
</h1>
</div>
</header>
<!-- Display toggle -->
<div id="primary" class="content-area">
<main id="main" class="site-main today-container">
<h2><a href="https://colinwalker.blog/otd/?date=2021-11-14" title="Click for \'On This Day\'" style="text-decoration: none;"><span class="dateSpan"><span class="daySpan">14/11/2021</a></span></span>
</h2>
<noscript>
<input id="dismiss" type="checkbox" checked><div class="warning">
Javascript appears to be disabled or not supported, this means that you will not be able to read or leave comments.<label for="dismiss">X</label>
</div>
</noscript>
<article id="p1"class="h-entry hentry" >
<h6 class="post_title">2021/11/14#p1</h6>
<div id="post1308">
<div class="section">
<a style="float: left;" class="u-url hash" href="https://colinwalker.blog/?date=2021-11-14#p1">#</a>
<a onclick="toggleComments(1308)" title="0 comments: click to read or leave your own" class="toggleComments"><picture class="commenticonpicture"><source srcset="/images/commentdark.png" media="(prefers-color-scheme: dark)"><img id="commenticon1308" class="commenticon" src="/images/comment.png" alt="0 comments: click to read or leave your own"></picture></a>
<div class="entry-content e-content p-name"><p>Lest we forget.</p>
<p><img loading="lazy" src="https://colinwalker.blog/uploads/2021/11/lestweforget.jpg" alt="Lest we forget" class="i80" /></p>
</div><!-- .entry-content -->
</div>
<time class="dt-published" datetime="2021-11-14T10:26:50+00:00"></time>
<div class="h-card p-author vcard author">
<img loading="lazy" class="u-photo" src="https://colinwalker.blog/images/colinwalker-thumb.jpg" alt="Colin Walker"/>
<a class="u-url" href="https://colinwalker.blog"><span class="p-name">Colin Walker</span></a>
</div>
</div>
<div id="edit1308" class="editdivs">
<iframe id="edit_upload_frame1308" scrolling="no" loading="lazy" src='/uploader.php' style="display: none; width: 100%; height: 30px; border: none; overflow: hidden;"></iframe>
<form name="form" method="post">
<input type="hidden" id="updatepost1308" name="updatepost" value="1308">
<textarea rows="10" id="newcontent1308" name="newcontent" class="newcontent text">Lest we forget.
![Lest we forget](https://colinwalker.blog/uploads/2021/11/lestweforget.jpg){.i80}</textarea>
<a onclick="quit(1308);"><img loading="lazy" style="width: 20px; float: left; position: relative; top: -1px; cursor: pointer;" alt="cancel" src="/images/cancel.png" /></a><span style="float: left; padding-left: 15px; font-size: 75%;">Draft: <input type="radio" name="status" value="draft" >&nbsp;&nbsp;Publish: <input type="radio" name="status" value="publish" checked="checked"></span>
<input style="float:right; font-size: 75%" type="submit" name="submit" id="submit1308" value="Update"><picture style="height: 17px; float: right; position: relative; right: 13px; top: 3px; cursor: pointer;"><source alt="media" srcset="/images/media_dark.png" media="(prefers-color-scheme: dark)"><img onclick="toggleImage_edit(1308);" style="height: 20px; float: right; position: relative; cursor: pointer;" alt="media" src="/images/media_light.png" /></picture>
</form>
</div><div id="replies1308" class="replies" style="height: 0px;"><div id="comment_section_1"></div><!-- #comments --><div id="leave_reply1308" class="leave_reply">Leave a reply</div>
<form method="post" name="comments" style="margin-bottom: 60px;">
<input type="hidden" value="590593081" name="commentcheck1308" />
<input type="hidden" name="PostID" value="1308">
<input type="hidden" name="InReplyTo" id="InReplyTo1308" value="">
<input type="text" id="check1308" name="check" value="" style="display: none;">
<input type="email" name="email" value="" placeholder="Email" style="visibility: hidden; height: 0px;"><br/>
<input id="name1308" type="text" name="name" value="" placeholder="Name *" size="30" style="font-family: Helvetica, Arial, sans-serif; font-size: 15px; margin-bottom: 10px; padding: 5px 7px; color: #777; border: 1px solid #ccc; border-radius: 5px;" required><br/>
<input type="url" name="website" value="" placeholder="Website" size="30" style="font-family: Helvetica, Arial, sans-serif; font-size: 15px; margin-bottom: 10px; padding: 5px 7px; color: #777; border: 1px solid #ccc; border-radius: 5px;"><br/>
<textarea id="comment_text1308" name="comment" rows="7" class="comment_text" style="color: #777; border: 1px solid #ccc; border-radius: 5px; font-family: Helvetica, Arial, sans-serif; font-size: 15px; margin-bottom: 5px; padding: 6px 7px;" required placeholder="Comment *"></textarea>
<div style="clear: both;"></div>
<a onclick="toggleComments(1308)" title="Cancel comment"><img src="/images/red-cross.png" alt="Cancel comment" style="float: left; width: 20px; cursor: pointer; margin-top: 2px;" /></a>
<input style="float:right; margin-top: 2px; margin-right: 16px;" type="submit" name="submit" id="comment_submit1308" value="Comment">
</form>
</div><!-- #replies -->
</article>
<article id="p3"class="h-entry hentry" >
<h6 class="post_title">2021/11/14#p3</h6>
<div id="post1313">
<div class="section">
<a style="float: left;" class="u-url hash" href="https://colinwalker.blog/?date=2021-11-14#p3">#</a>
<a onclick="toggleComments(1313)" title="0 comments: click to read or leave your own" class="toggleComments"><picture class="commenticonpicture"><source srcset="/images/commentdark.png" media="(prefers-color-scheme: dark)"><img id="commenticon1313" class="commenticon" src="/images/comment.png" alt="0 comments: click to read or leave your own"></picture></a>
<p class="replyto"><em>In reply to: <a class="u-in-reply-to" href="https://jlelse.blog/micro/2021/11/2021-11-13-lrhvj">jlelse’s Blog</a>...</em></p><div class="entry-content e-content p-name"><p>Congratulations on a year of GoBlog 👏</p>
<p>My year anniversary with (b)log-In is in January.</p>
</div><!-- .entry-content -->
</div>
<time class="dt-published" datetime="2021-11-14T23:27:13+00:00"></time>
<div class="h-card p-author vcard author">
<img loading="lazy" class="u-photo" src="https://colinwalker.blog/images/colinwalker-thumb.jpg" alt="Colin Walker"/>
<a class="u-url" href="https://colinwalker.blog"><span class="p-name">Colin Walker</span></a>
</div>
</div>
<div id="edit1313" class="editdivs">
<iframe id="edit_upload_frame1313" scrolling="no" loading="lazy" src='/uploader.php' style="display: none; width: 100%; height: 30px; border: none; overflow: hidden;"></iframe>
<form name="form" method="post">
<input type="hidden" id="updatepost1313" name="updatepost" value="1313">
<textarea rows="10" id="newcontent1313" name="newcontent" class="newcontent text">(r(https://jlelse.blog/micro/2021/11/2021-11-13-lrhvj)r)
Congratulations on a year of GoBlog 👏
My year anniversary with !blogin! is in January.</textarea>
<a onclick="quit(1313);"><img loading="lazy" style="width: 20px; float: left; position: relative; top: -1px; cursor: pointer;" alt="cancel" src="/images/cancel.png" /></a><span style="float: left; padding-left: 15px; font-size: 75%;">Draft: <input type="radio" name="status" value="draft" >&nbsp;&nbsp;Publish: <input type="radio" name="status" value="publish" checked="checked"></span>
<input style="float:right; font-size: 75%" type="submit" name="submit" id="submit1313" value="Update"><picture style="height: 17px; float: right; position: relative; right: 13px; top: 3px; cursor: pointer;"><source alt="media" srcset="/images/media_dark.png" media="(prefers-color-scheme: dark)"><img onclick="toggleImage_edit(1313);" style="height: 20px; float: right; position: relative; cursor: pointer;" alt="media" src="/images/media_light.png" /></picture>
</form>
</div><div id="replies1313" class="replies" style="height: 0px;"><div id="comment_section_3"></div><!-- #comments --><div id="leave_reply1313" class="leave_reply">Leave a reply</div>
<form method="post" name="comments" style="margin-bottom: 60px;">
<input type="hidden" value="1287580429" name="commentcheck1313" />
<input type="hidden" name="PostID" value="1313">
<input type="hidden" name="InReplyTo" id="InReplyTo1313" value="">
<input type="text" id="check1313" name="check" value="" style="display: none;">
<input type="email" name="email" value="" placeholder="Email" style="visibility: hidden; height: 0px;"><br/>
<input id="name1313" type="text" name="name" value="" placeholder="Name *" size="30" style="font-family: Helvetica, Arial, sans-serif; font-size: 15px; margin-bottom: 10px; padding: 5px 7px; color: #777; border: 1px solid #ccc; border-radius: 5px;" required><br/>
<input type="url" name="website" value="" placeholder="Website" size="30" style="font-family: Helvetica, Arial, sans-serif; font-size: 15px; margin-bottom: 10px; padding: 5px 7px; color: #777; border: 1px solid #ccc; border-radius: 5px;"><br/>
<textarea id="comment_text1313" name="comment" rows="7" class="comment_text" style="color: #777; border: 1px solid #ccc; border-radius: 5px; font-family: Helvetica, Arial, sans-serif; font-size: 15px; margin-bottom: 5px; padding: 6px 7px;" required placeholder="Comment *"></textarea>
<div style="clear: both;"></div>
<a onclick="toggleComments(1313)" title="Cancel comment"><img src="/images/red-cross.png" alt="Cancel comment" style="float: left; width: 20px; cursor: pointer; margin-top: 2px;" /></a>
<input style="float:right; margin-top: 2px; margin-right: 16px;" type="submit" name="submit" id="comment_submit1313" value="Comment">
</form>
</div><!-- #replies -->
</article>
<article id="p2"class="h-entry hentry" >
<h6 class="post_title">2021/11/14#p2</h6>
<div id="post1309">
<div class="section">
<a style="float: left;" class="u-url hash" href="https://colinwalker.blog/?date=2021-11-14#p2">#</a>
<a onclick="toggleComments(1309)" title="0 comments: click to read or leave your own" class="toggleComments"><picture class="commenticonpicture"><source srcset="/images/commentdark.png" media="(prefers-color-scheme: dark)"><img id="commenticon1309" class="commenticon" src="/images/comment.png" alt="0 comments: click to read or leave your own"></picture></a>
<div class="entry-content e-content p-name"><p>Just had my flu jab for the winter. My Covid booster is due in just under a month.</p>
</div><!-- .entry-content -->
</div>
<time class="dt-published" datetime="2021-11-14T13:10:01+00:00"></time>
<div class="h-card p-author vcard author">
<img loading="lazy" class="u-photo" src="https://colinwalker.blog/images/colinwalker-thumb.jpg" alt="Colin Walker"/>
<a class="u-url" href="https://colinwalker.blog"><span class="p-name">Colin Walker</span></a>
</div>
</div>
<div id="edit1309" class="editdivs">
<iframe id="edit_upload_frame1309" scrolling="no" loading="lazy" src='/uploader.php' style="display: none; width: 100%; height: 30px; border: none; overflow: hidden;"></iframe>
<form name="form" method="post">
<input type="hidden" id="updatepost1309" name="updatepost" value="1309">
<textarea rows="10" id="newcontent1309" name="newcontent" class="newcontent text">Just had my flu jab for the winter. My Covid booster is due in just under a month.</textarea>
<a onclick="quit(1309);"><img loading="lazy" style="width: 20px; float: left; position: relative; top: -1px; cursor: pointer;" alt="cancel" src="/images/cancel.png" /></a><span style="float: left; padding-left: 15px; font-size: 75%;">Draft: <input type="radio" name="status" value="draft" >&nbsp;&nbsp;Publish: <input type="radio" name="status" value="publish" checked="checked"></span>
<input style="float:right; font-size: 75%" type="submit" name="submit" id="submit1309" value="Update"><picture style="height: 17px; float: right; position: relative; right: 13px; top: 3px; cursor: pointer;"><source alt="media" srcset="/images/media_dark.png" media="(prefers-color-scheme: dark)"><img onclick="toggleImage_edit(1309);" style="height: 20px; float: right; position: relative; cursor: pointer;" alt="media" src="/images/media_light.png" /></picture>
</form>
</div><div id="replies1309" class="replies" style="height: 0px;"><div id="comment_section_2"></div><!-- #comments --><div id="leave_reply1309" class="leave_reply">Leave a reply</div>
<form method="post" name="comments" style="margin-bottom: 60px;">
<input type="hidden" value="133084696" name="commentcheck1309" />
<input type="hidden" name="PostID" value="1309">
<input type="hidden" name="InReplyTo" id="InReplyTo1309" value="">
<input type="text" id="check1309" name="check" value="" style="display: none;">
<input type="email" name="email" value="" placeholder="Email" style="visibility: hidden; height: 0px;"><br/>
<input id="name1309" type="text" name="name" value="" placeholder="Name *" size="30" style="font-family: Helvetica, Arial, sans-serif; font-size: 15px; margin-bottom: 10px; padding: 5px 7px; color: #777; border: 1px solid #ccc; border-radius: 5px;" required><br/>
<input type="url" name="website" value="" placeholder="Website" size="30" style="font-family: Helvetica, Arial, sans-serif; font-size: 15px; margin-bottom: 10px; padding: 5px 7px; color: #777; border: 1px solid #ccc; border-radius: 5px;"><br/>
<textarea id="comment_text1309" name="comment" rows="7" class="comment_text" style="color: #777; border: 1px solid #ccc; border-radius: 5px; font-family: Helvetica, Arial, sans-serif; font-size: 15px; margin-bottom: 5px; padding: 6px 7px;" required placeholder="Comment *"></textarea>
<div style="clear: both;"></div>
<a onclick="toggleComments(1309)" title="Cancel comment"><img src="/images/red-cross.png" alt="Cancel comment" style="float: left; width: 20px; cursor: pointer; margin-top: 2px;" /></a>
<input style="float:right; margin-top: 2px; margin-right: 16px;" type="submit" name="submit" id="comment_submit1309" value="Comment">
</form>
</div><!-- #replies -->
</article>
<div style="clear: both;"></div>
</main><!-- #main -->
</div><!-- #primary -->
</div><!-- #page -->
<nav class="navigation paging-navigation">
<div class="nav-links">
<div class="nav-previous"><a accesskey="j" href="https://colinwalker.blog?date=2021-11-13" title="Previous day"><<</a></div><div class="nav-next"><a accesskey="k" href="https://colinwalker.blog?date=2021-11-15" title="Next day">>></a></div>
</div><!-- .nav-links -->
</nav><!-- .navigation -->
<div class="linksDiv day-links"><a href="https://colinwalker.blog">Today</a>|<a accesskey="s" style="text-decoration: none;" title="Search" href="/search/"><picture class="searchicon"><source srcset="/images/search_dark.png" media="(prefers-color-scheme: dark)"><img class="searchicon" src="/images/search_light.png" alt="Search the blog"></picture></a>|<a accesskey="r" class="randomlink" style="text-decoration: none;" title="Random post" href="/random/">?</a>|<a href="/joinme/" title="Subscribe to regular & daily RSS feeds & the muse-letter">Join me</a>
</div>
<script>
var PostID = '';
if(PostID != '') {
toggleComments(PostID);
}
fragmention();
</script>
<script type="text/javascript" src="/jquery.slim.min.js"></script>
<script type="text/javascript" src="/bigfoot/bigfoot.min.js"></script>
<script type="text/javascript">
var bigfoot = $.bigfoot( {
positionContent: true,
preventPageScroll: true
} );
</script>
<script>
var hash;
var id;
var replies;
var repliesArray;
var section;
var sectionArray;
var trueHeight;
hash = window.location.hash;
if (hash != '') {
hash = hash.slice(2);
id = "p" + hash;
replies = document.getElementById(id).getElementsByClassName('replies')[0];
replies.style.transition = "all 0s";
trueHeight = replies.scrollHeight+30;
replies.style.height = trueHeight + "px";
replies.style.marginTop = "30px";
replies.style.marginBottom = "30px";
replies.style.padding = "20px 15px 0px";
section = document.getElementById(id);
var top = section.offsetTop;
window.scrollTo(0, top-50);
}
$(window).bind('hashchange', function() {
hash = window.location.hash;
hash = hash.slice(2);
id = "p" + hash;
repliesArray = document.getElementsByClassName("replies");
for (var i = 0; i < repliesArray.length; i++) {
repliesArray[i].style.height = "0px";
repliesArray[i].style.marginTop = "0px";
repliesArray[i].style.marginBottom = "0px";
repliesArray[i].style.padding = "0px";
}
replies = document.getElementById(id).getElementsByClassName('replies')[0];
replies.style.transition = "all 0s";
trueHeight = replies.scrollHeight;
replies.style.height = trueHeight + "px";
replies.style.marginTop = "30px";
replies.style.marginBottom = "30px";
replies.style.padding = "20px 15px 0px";
id = "p" + hash;
section = document.getElementById(id);
var top = section.offsetTop;
window.scrollTo(0, top-50);
});
queryString = window.location.search;
urlParams = new URLSearchParams(queryString);
comment = urlParams.get("c");
if (comment != null) {
scArray = comment.split(":");
section = scArray[0];
comment_no = scArray[1];
cid = "p" + section + comment_no;
id = "p" + section;
replies = document.getElementById(id).getElementsByClassName('replies')[0];
replies.style.transition = "all 0s";
trueHeight = replies.scrollHeight;
replies.style.height = trueHeight + "px";
replies.style.marginTop = "30px";
replies.style.marginBottom = "30px";
replies.style.padding = "20px 15px 0px";
section_no = "comment_section_"+section;
if (document.getElementById(cid)) {
commentid = document.getElementById(cid);
} else {
commentArray = document.getElementById(section_no).querySelectorAll(".comment");
commentid = commentArray[comment_no-1];
}
console.log(commentid.classList.value);
commentid.classList.add("linkedComment");
rect = commentid.getBoundingClientRect();
recttop = rect.top;
window.scrollTo(0, recttop-100);
}
function setInReplyTo(post) {
res = post.split(',');
var postid = "name"+res[0];
var irt = "InReplyTo"+res[0];
var replyspan = "leave_reply"+res[0];
replyto = document.getElementById(replyspan);
replyto.innerText = "Replying to "+res[2];
document.getElementById(irt).value = res[1];
document.getElementById(postid).setSelectionRange(0, 0);
document.getElementById(postid).focus();
rect = replyto.getBoundingClientRect();
recttop = rect.top;
window.scrollTo(0, recttop);
replyto.classList.add("flash");
setTimeout(function(){ replyto.classList.remove("flash"); }, 1000);
}
var clickable = document.getElementsByClassName("clickable");
var x = new Array();
for (i = 0; i < clickable.length; i++) {
x[i] = clickable[i].innerHTML;
clickable[i].innerHTML = x[i] + "<div style='height: 0px; position: relative; width: 50%; margin: 0 auto;'><img src='/images/expand.png' class='overlay noradius'></div>";
}
var clickabledark = document.getElementsByClassName("clickabledark");
var x = new Array();
for (i = 0; i < clickabledark.length; i++) {
x[i] = clickabledark[i].innerHTML;
clickabledark[i].innerHTML = x[i] + "<div style='height: 0px; position: relative; width: 50%; margin: 0 auto;'><img src='/images/expanddark.png' class='overlay noradius'></div>";
}
</script>
<div id="siteID" class="siteID">
<span class="nameSpan">
<a href="/about/">About</a>
</span>
<br/>
<span class="licSpan">
<a href="/colophon/">COLOPHON</a> </span>
</div>
<div class="h-card p-author vcard author">
<img class="u-photo" src="https://colinwalker.blog/images/colinwalker-thumb.jpg" alt="Colin Walker"/>
<a class="u-url u-uid" rel="me" href="https://colinwalker.blog">Colin Walker</a>
<a rel="me" class="u-email" href="mailto:colin@colinwalker.blog">colin@colinwalker.blog</a>
<p class="p-note"></p>
</div>
<style>
@media screen and (max-width: 767px) {
#page {
min-height: calc(100vh - 282px) !important;
}
}
</style>
<style>
@media screen and (min-width: 768px) {
#page {
min-height: calc(100vh - 210px) !important;
}
}
</style>
</body>
</html>

11
webmentionVerification.go

@ -260,7 +260,7 @@ func (m *mention) fill(mf *microformats.Microformat) bool {
m.fillContent(mf)
// Author
m.fillAuthor(mf)
return true
return m.hasUrl
}
for _, mfc := range mf.Children {
if m.fill(mfc) {
@ -271,6 +271,9 @@ func (m *mention) fill(mf *microformats.Microformat) bool {
}
func (m *mention) fillTitle(mf *microformats.Microformat) {
if m.Title != "" {
return
}
if name, ok := mf.Properties["name"]; ok && len(name) > 0 {
if title, ok := name[0].(string); ok {
m.Title = strings.TrimSpace(title)
@ -279,6 +282,9 @@ func (m *mention) fillTitle(mf *microformats.Microformat) {
}
func (m *mention) fillContent(mf *microformats.Microformat) {
if m.Content != "" {
return
}
if contents, ok := mf.Properties["content"]; ok && len(contents) > 0 {
if content, ok := contents[0].(map[string]string); ok {
if contentHTML, ok := content["html"]; ok {
@ -295,6 +301,9 @@ func (m *mention) fillContent(mf *microformats.Microformat) {
}
func (m *mention) fillAuthor(mf *microformats.Microformat) {
if m.Author != "" {
return
}
if authors, ok := mf.Properties["author"]; ok && len(authors) > 0 {
if author, ok := authors[0].(*microformats.Microformat); ok {
if names, ok := author.Properties["name"]; ok && len(names) > 0 {

43
webmentionVerification_test.go

@ -101,3 +101,46 @@ func Test_verifyMentionBidgy(t *testing.T) {
require.Equal(t, "comment test", m.Content)
require.Equal(t, "m4rk", m.Author)
}
func Test_verifyMentionColin(t *testing.T) {
testHtmlBytes, err := os.ReadFile("testdata/colin.html")
require.NoError(t, err)
testHtml := string(testHtmlBytes)
mockClient := &fakeHttpClient{}
mockClient.setFakeResponse(http.StatusOK, testHtml)
app := &goBlog{
httpClient: mockClient,
cfg: &config{
Db: &configDb{
File: filepath.Join(t.TempDir(), "test.db"),
},
Server: &configServer{
PublicAddress: "https://jlelse.blog",
},
},
d: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// do nothing
}),
}
_ = app.initDatabase(false)
app.initComponents(false)
m := &mention{
Source: "https://colinwalker.blog/?date=2021-11-14#p3",
Target: "https://jlelse.blog/micro/2021/11/2021-11-13-lrhvj",
}
err = app.verifyMention(m)
require.NoError(t, err)
require.Equal(t, "https://jlelse.blog/micro/2021/11/2021-11-13-lrhvj", m.Target)
require.Equal(t, "https://colinwalker.blog/?date=2021-11-14#p3", m.Source)
require.Equal(t, "https://colinwalker.blog/?date=2021-11-14#p3", m.Url)
require.True(t, strings.HasPrefix(m.Title, "Congratulations"))
require.True(t, strings.HasPrefix(m.Content, "Congratulations"))
require.Equal(t, "Colin Walker", m.Author)
}

Loading…
Cancel
Save