From b61d86335672962becbd97c03984f14b1ae5644f Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Wed, 1 Sep 2021 10:53:45 +0200 Subject: [PATCH] Fixed merge conflicts --- CHANGELOG.md | 23 ++++++++++++++++++++--- src/short-urls/ShortUrlsList.tsx | 2 +- src/tags/TagCard.tsx | 2 +- test/tags/TagCard.test.tsx | 24 +++++++++++++++--------- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 363b2b14..484e39d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,13 +4,30 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org). +## [Unreleased] +### Added +* *Nothing* + +### Changed +* *Nothing* + +### Deprecated +* *Nothing* + +### Removed +* *Nothing* + +### Fixed +* [#478](https://github.com/shlinkio/shlink-web-client/pull/478) Fixed tags including special chars not being properly URL encoded before using them as query params. + + ## [3.2.0] - 2021-07-12 ### Added * [#433](https://github.com/shlinkio/shlink-web-client/pull/433) Added support to provide a default server to connect to via env vars: - * `SHLINK_SERVER_URL`: The URL of the Shlink server to configure by default. - * `SHLINK_SERVER_API_KEY`: The API key of the Shlink server. - * `SHLINK_SERVER_NAME`: A name you want to give to this server. Defaults to *Shlink* if not provided. + * `SHLINK_SERVER_URL`: The URL of the Shlink server to configure by default. + * `SHLINK_SERVER_API_KEY`: The API key of the Shlink server. + * `SHLINK_SERVER_NAME`: A name you want to give to this server. Defaults to *Shlink* if not provided. * [#432](https://github.com/shlinkio/shlink-web-client/pull/432) Added support to provide the `servers.json` file inside a `conf.d` folder. * [#440](https://github.com/shlinkio/shlink-web-client/pull/440) Added hint of what visits come potentially from a bot, in the visits table, when consuming Shlink >=2.7. diff --git a/src/short-urls/ShortUrlsList.tsx b/src/short-urls/ShortUrlsList.tsx index 4736bc8c..ef24eb5b 100644 --- a/src/short-urls/ShortUrlsList.tsx +++ b/src/short-urls/ShortUrlsList.tsx @@ -70,7 +70,7 @@ const ShortUrlsList = (ShortUrlsTable: FC) => boundToMercur useEffect(() => { const { tag } = parseQuery<{ tag?: string }>(location.search); - const tags = tag ? [ tag ] : shortUrlsListParams.tags; + const tags = tag ? [ decodeURIComponent(tag) ] : shortUrlsListParams.tags; refreshList({ page: match.params.page, tags, itemsPerPage: undefined }); diff --git a/src/tags/TagCard.tsx b/src/tags/TagCard.tsx index b72bca0e..05b4f13e 100644 --- a/src/tags/TagCard.tsx +++ b/src/tags/TagCard.tsx @@ -30,7 +30,7 @@ const TagCard = ( const [ isEditModalOpen, toggleEdit ] = useToggle(); const serverId = isServerWithId(selectedServer) ? selectedServer.id : ''; - const shortUrlsLink = `/server/${serverId}/list-short-urls/1?tag=${tag}`; + const shortUrlsLink = `/server/${serverId}/list-short-urls/1?tag=${encodeURIComponent(tag)}`; return ( diff --git a/test/tags/TagCard.test.tsx b/test/tags/TagCard.test.tsx index 38d1abbe..db1dce18 100644 --- a/test/tags/TagCard.test.tsx +++ b/test/tags/TagCard.test.tsx @@ -14,30 +14,36 @@ describe('', () => { }; const DeleteTagConfirmModal = jest.fn(); const EditTagModal = jest.fn(); - - beforeEach(() => { - const TagCard = createTagCard(DeleteTagConfirmModal, EditTagModal, () => null, Mock.all()); - + const TagCard = createTagCard(DeleteTagConfirmModal, EditTagModal, () => null, Mock.all()); + const createWrapper = (tag = 'ssr') => { wrapper = shallow( ({ id: '1' })} tagStats={tagStats} displayed={true} toggle={() => {}} />, ); - }); + + return wrapper; + }; + + beforeEach(() => createWrapper()); afterEach(() => wrapper.unmount()); afterEach(jest.resetAllMocks); - it('shows a TagBullet and a link to the list filtering by the tag', () => { + it.each([ + [ 'ssr', '/server/1/list-short-urls/1?tag=ssr' ], + [ 'ssr-&-foo', '/server/1/list-short-urls/1?tag=ssr-%26-foo' ], + ])('shows a TagBullet and a link to the list filtering by the tag', (tag, expectedLink) => { + const wrapper = createWrapper(tag); const links = wrapper.find(Link); const bullet = wrapper.find(TagBullet); - expect(links.at(0).prop('to')).toEqual('/server/1/list-short-urls/1?tag=ssr'); - expect(bullet.prop('tag')).toEqual('ssr'); + expect(links.at(0).prop('to')).toEqual(expectedLink); + expect(bullet.prop('tag')).toEqual(tag); }); it('displays delete modal when delete btn is clicked', () => {