Bluesky app fork with some witchin' additions 💫 witchsky.app
bluesky fork client
122
fork

Configure Feed

Select the types of activity you want to include in your feed.

Only warn on links to bsky.app if it represents itself as another url (#1662)

* Only warn on links to bsky.app if it represents itself as another url (close #1652)

* Clean up

authored by

Paul Frazee and committed by
GitHub
4d450da1 e878da04

+58 -5
+36
__tests__/lib/strings/url-helpers.test.ts
··· 27 27 ['http://site.pages', 'http://site.pages.dev', true], 28 28 ['http://site.pages.dev', 'site.pages', true], 29 29 ['http://site.pages', 'site.pages.dev', true], 30 + ['http://bsky.app/profile/bob.test/post/3kbeuduu7m22v', 'my post', false], 31 + ['https://bsky.app/profile/bob.test/post/3kbeuduu7m22v', 'my post', false], 32 + ['http://bsky.app/', 'bluesky', false], 33 + ['https://bsky.app/', 'bluesky', false], 34 + [ 35 + 'http://bsky.app/profile/bob.test/post/3kbeuduu7m22v', 36 + 'http://bsky.app/profile/bob.test/post/3kbeuduu7m22v', 37 + false, 38 + ], 39 + [ 40 + 'https://bsky.app/profile/bob.test/post/3kbeuduu7m22v', 41 + 'http://bsky.app/profile/bob.test/post/3kbeuduu7m22v', 42 + false, 43 + ], 44 + [ 45 + 'http://bsky.app/', 46 + 'http://bsky.app/profile/bob.test/post/3kbeuduu7m22v', 47 + false, 48 + ], 49 + [ 50 + 'https://bsky.app/', 51 + 'http://bsky.app/profile/bob.test/post/3kbeuduu7m22v', 52 + false, 53 + ], 54 + [ 55 + 'http://bsky.app/profile/bob.test/post/3kbeuduu7m22v', 56 + 'https://google.com', 57 + true, 58 + ], 59 + [ 60 + 'https://bsky.app/profile/bob.test/post/3kbeuduu7m22v', 61 + 'https://google.com', 62 + true, 63 + ], 64 + ['http://bsky.app/', 'https://google.com', true], 65 + ['https://bsky.app/', 'https://google.com', true], 30 66 31 67 // bad uri inputs, default to true 32 68 ['', '', true],
+22 -5
src/lib/strings/url-helpers.ts
··· 170 170 171 171 export function linkRequiresWarning(uri: string, label: string) { 172 172 const labelDomain = labelToDomain(label) 173 - if (!labelDomain) { 173 + let urip 174 + try { 175 + urip = new URL(uri) 176 + } catch { 174 177 return true 175 178 } 176 - try { 177 - const urip = new URL(uri) 179 + 180 + if (urip.hostname === 'bsky.app') { 181 + // if this is a link to internal content, 182 + // warn if it represents itself as a URL to another app 183 + if ( 184 + labelDomain && 185 + labelDomain !== 'bsky.app' && 186 + isPossiblyAUrl(labelDomain) 187 + ) { 188 + return true 189 + } 190 + return false 191 + } else { 192 + // if this is a link to external content, 193 + // warn if the label doesnt match the target 194 + if (!labelDomain) { 195 + return true 196 + } 178 197 return labelDomain !== urip.hostname 179 - } catch { 180 - return true 181 198 } 182 199 } 183 200