From 6ac721e9e57cbfe6ebcd49bbe98726e103438129 Mon Sep 17 00:00:00 2001 From: Charles Iliya Krempeaux Date: Thu, 15 Feb 2024 05:08:45 -0800 Subject: [PATCH] initial commits --- stringframeposturl.go | 17 ++++++++++ stringframeposturl_test.go | 63 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 stringframeposturl.go create mode 100644 stringframeposturl_test.go diff --git a/stringframeposturl.go b/stringframeposturl.go new file mode 100644 index 0000000..570cd30 --- /dev/null +++ b/stringframeposturl.go @@ -0,0 +1,17 @@ +package frameproto + +// StringFramePostURL will return the HTML element for the Frame-Protocol's (i.e., Farcaster Frame's) "fc:frame:post_url" name-value pair. +// +// For example, this call: +// +// var url string = "https://example.com/my/post/path.php" +// +// str := frameproto.StringFramePostURL(url) +// +// Would return this HTML element: +// +// +func StringFramePostURL(url string) string { + const property string = MetaPropertyFramePostURL + return stringMetaPropertyContent(property, url) +} diff --git a/stringframeposturl_test.go b/stringframeposturl_test.go new file mode 100644 index 0000000..6355199 --- /dev/null +++ b/stringframeposturl_test.go @@ -0,0 +1,63 @@ +package frameproto + +import ( + "testing" +) + +func TestStringFramePostURL(t *testing.T) { + + tests := []struct{ + URL string + Expected string + }{ + { + URL: "", + Expected: ``+"\n", + }, + + + + { + URL: "something", + Expected: ``+"\n", + }, + + + + { + URL: "Hello world! 🙂", + Expected: ``+"\n", + }, + + + + { + URL: "https://example.com/path/to/post/to.php", + Expected: ``+"\n", + }, + + + + { + URL: "x-proto:apple/banana/cherry", + Expected: ``+"\n", + }, + } + + for testNumber, test := range tests { + + actual := StringFramePostURL(test.URL) + + expected := test.Expected + + if expected != actual { + t.Errorf("For test #%d, the actual written meta-tag is not what was expected." ,testNumber) + t.Logf("EXPECTED: %s", expected) + t.Logf("ACTUAL: %s", actual) + t.Logf("EXPECTED: %q", expected) + t.Logf("ACTUAL: %q", actual) + t.Logf("URL: %q", test.URL) + continue + } + } +}