updates plug with all sorts of awesome improvements

This commit is contained in:
2026-11-09 13:09:09 +01:00
parent a92d6f8871
commit 3afdb6d67f
553 changed files with 22780 additions and 13155 deletions
+28
View File
@@ -0,0 +1,28 @@
import Foundation
import PlakCore
import Testing
@Suite struct PageLinkTests {
private let text = "see https://plak.app/a?b=1 and\nmail jo@example.com\nplain words" as NSString
@Test("an index inside a web address gives the address and its range")
func web() throws {
let link = try #require(PageLink.link(in: text, at: 10))
#expect(link.url.absoluteString == "https://plak.app/a?b=1")
#expect(link.range == NSRange(location: 4, length: 22))
}
@Test("a mail address on a later line is a mailto link")
func mail() throws {
let link = try #require(PageLink.link(in: text, at: 40))
#expect(link.url.absoluteString == "mailto:jo@example.com")
}
@Test("an index outside an address, or out of the text, gives no link")
func none() {
#expect(PageLink.link(in: text, at: 1) == nil)
#expect(PageLink.link(in: text, at: text.length - 2) == nil)
#expect(PageLink.link(in: text, at: text.length) == nil)
#expect(PageLink.link(in: text, at: -1) == nil)
}
}