{{ $t('changelog.error.p1', { package: pkgName }) }}
diff --git a/app/components/Changelog/Markdown.vue b/app/components/Changelog/Markdown.vue index a81fd86541..7c5dc9558e 100644 --- a/app/components/Changelog/Markdown.vue +++ b/app/components/Changelog/Markdown.vue @@ -8,9 +8,14 @@ const { info, goToVersion, tpTarget, resolveVersionPending } = defineProps<{ const route = useRoute() -const { data, error, pending } = useLazyFetch( - () => `/api/changelog/md/${info.provider}/${info.repo}/${info.path}`, -) +const url = computed(() => `/api/changelog/md/${info.provider}/${info.repo}/${info.path}` as const) +const host = computed(() => info.host) + +const { data, error, pending } = useLazyFetch(url, { + query: { + host, + }, +}) if (import.meta.client) { const { settings } = useSettings() @@ -18,7 +23,7 @@ if (import.meta.client) { // doing this server side can make it that we go to the homepage const stopWatching = watchEffect( () => { - if (resolveVersionPending) { + if (resolveVersionPending || typeof data.value == 'string') { return // need to wait till resolving is finished } const toc = data.value?.toc @@ -50,11 +55,33 @@ if (import.meta.client) { // stops watchEffect from trigger just before navigating onBeforeRouteLeave(stopWatching) } + +// fetch raw markdown to copy +const { + data: rawMarkdown, + execute: fetchMarkdown, + status: mdStatus, +} = useLazyFetch#2869 hello
\n#2717 world
\n', + ) + }) + + it("shouldn't turn issues/PRs in list into headings but into links", async () => { + const info = changelogMdinfo() + const renderer = await changelogRenderer(info) + const markdown = `- #2869 hello +- #2717 world` + + const result = renderer(markdown) + expect(result.html).toBe( + '\n', + ) + }) + }) + + it('should turn issue/pr & account into links', async () => { const info = changelogMdinfo() const renderer = await changelogRenderer(info) - const markdown = `#2869 hello + // text from date-fns v4.3.0 + const markdown = `- Fixed pt locale first day of week to be Sunday. See #4195 by @ImRodry. +- Fixed zh-CN, zh-HK, and zh-TW locale month parsing for October, November, and December. See #4194 by @puneetdixit200. +` + const result = renderer(markdown) -#2717 world` + expect(result.html).toBe(`#2869 hello
\n#2717 world
\n') + + expect(result.html).toBe(` +`) }) - it("shouldn't turn issues/PRs in list into headings", async () => { + it('should turn mutliple issue/pr after each other issues/pr into links', async () => { + const info = changelogMdinfo() + const renderer = await changelogRenderer(info) + // test from fullcalendar v6.1.18 + const markdown = 'fix: Optimize custom content-injection rerendering performance (#3003, #7650)' + + const result = renderer(markdown) + + expect(result.html).toBe( + `fix: Optimize custom content-injection rerendering performance (#3003, #7650)
\n`, + ) + }) + + it('should turn accounts into lists', async () => { + const info = changelogMdinfo() + const renderer = await changelogRenderer(info) + // from npmx release 0.13.0, wanted to a release with many accounts mentioned + const markdown = `### ❤️ Contributors\n\n- Daniel Roe (@danielroe)\n- Alex Savelyev (@alexdln)\n- Alec Lloyd Probert (@graphieros)\n- cylewaitforit (@cylewaitforit)\n- Vinayak (@VinayakMaharaj)\n- Robin de Vos (@Codefoxdev)\n- Patrick Dewey (@ptdewey)\n- Dominik Dorfmeister 🔮 (@TkDodo)\n- Philippe Serhal (@serhalp)\n- Wilco (@WilcoSp)\n- Willow (GHOST) (@ghostdevv)\n- Aryan Pingle (@aryanpingle)\n- Roman (@gameroman)\n- Matteo Gabriele (@MatteoGabriele)\n- Alberto Rico (@alrico88)\n- TAKAHASHI Shuuji (@shuuji3)\n- Bugo (@dragomano)\n- Sasha (@Sasha125588)\n- Iestyn (@IestynGage)\n- Torben Haack (@t128n)\n- Mutsumi (@BabyLy233)\n- Bonsak Schiledrop (@bonsak)\n` + + const result = renderer(markdown) + + expect(result.html) + .toBe(`lorem ipsum is fixed in #1234567
\n`, + ) + }) + + it('should format gitlab merge requests', async () => { + const info = createGitLabRepoInfo('gitlab.com', 'test', 'test') + const renderer = await changelogRenderer(info) + + const markdown = `!123 hallo\n\nhttps://gitlab.com/test/test/-/merge_requests/321 world` + const result = renderer(markdown) + + expect(result.html).toBe( + `!123 hallo
+!321 world
+`, + ) + }) + + it('should format at proto @account handle but not @version', async () => { + const info = changelogMdinfo() + const renderer = await changelogRenderer(info) + + const markdown = `nppmx @npmx.dev\n\n3po @3po.at.proto\n\nlorem @1.2.3 ipsum` + const result = renderer(markdown) + + expect(result.html).toBe( + `nppmx @npmx.dev
+3po @3po.at.proto
+lorem @1.2.3 ipsum
+`, + ) + }) + + it("shouldn't format package@version", async () => { + const info = changelogMdinfo() + const renderer = await changelogRenderer(info) + const markdown = `install package with package@latest or specific version like package@1.2.3` + + const result = renderer(markdown) + expect(result.html).toBe( + `install package with package@latest or specific version like package@1.2.3
+`, + ) + }) + + it("shouldn't format email as git link", async () => { + const info = changelogMdinfo() + const renderer = await changelogRenderer(info) + const markdown = `email to test@package.test to get in contact` + + const result = renderer(markdown) + expect(result.html).toBe( + `email to test@package.test to get in contact
+`, + ) + }) +}) + +describe('format unformatted/auto links to git', () => { + // links to account won't be formatted, this is something also git providers don't do + it('should turn issue, pr, commit & compare links to formatted links', async () => { + const info = createGithubRepoInfo('vueuse', 'vueuse') + const renderer = await changelogRenderer(info) + // from vueuse 14.3.0 (last 2 links changed from `issues` -> `pull`) + const markdown = `- Expose pointer event onLongPress - by mrcwbr in https://github.com/vueuse/vueuse/issues/5295 https://github.com/vueuse/vueuse/commit/b1688bd2 +- createInjectionState: Non-undefined return when default specified - by Laupetin in https://github.com/vueuse/vueuse/issues/5306 https://github.com/vueuse/vueuse/commit/b0c51c27 +- createReusableTemplate: Add support for specifying component names - by wbolster in https://github.com/vueuse/vueuse/pull/5300 https://github.com/vueuse/vueuse/commit/ea29d5cb +- nuxt: Add composable variants to auto imports - by OrbisK in https://github.com/vueuse/vueuse/issues/5285 https://github.com/vueuse/vueuse/commit/ac2ef95d + +https://github.com/vueuse/vueuse/compare/v14.2.1...v14.3.0` + + const result = renderer(markdown) + expect(result.html).toBe(`