mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Merge pull request #479 from acelaya-forks/feature/tag-special-chars
Fixed tags including special chars being broken when used in URLs
This commit is contained in:
commit
aceb2350cf
4 changed files with 18 additions and 12 deletions
|
@ -27,7 +27,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
* *Nothing*
|
* *Nothing*
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
* *Nothing*
|
* [#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
|
## [3.2.0] - 2021-07-12
|
||||||
|
|
|
@ -70,7 +70,7 @@ const ShortUrlsList = (ShortUrlsTable: FC<ShortUrlsTableProps>) => boundToMercur
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const { tag } = parseQuery<{ tag?: string }>(location.search);
|
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 });
|
refreshList({ page: match.params.page, tags, itemsPerPage: undefined });
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ const TagCard = (
|
||||||
const titleRef = useRef<HTMLElement>();
|
const titleRef = useRef<HTMLElement>();
|
||||||
|
|
||||||
const serverId = isServerWithId(selectedServer) ? selectedServer.id : '';
|
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)}`;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isTruncated(titleRef.current)) {
|
if (isTruncated(titleRef.current)) {
|
||||||
|
|
|
@ -14,30 +14,36 @@ describe('<TagCard />', () => {
|
||||||
};
|
};
|
||||||
const DeleteTagConfirmModal = jest.fn();
|
const DeleteTagConfirmModal = jest.fn();
|
||||||
const EditTagModal = jest.fn();
|
const EditTagModal = jest.fn();
|
||||||
|
const TagCard = createTagCard(DeleteTagConfirmModal, EditTagModal, () => null, Mock.all<ColorGenerator>());
|
||||||
beforeEach(() => {
|
const createWrapper = (tag = 'ssr') => {
|
||||||
const TagCard = createTagCard(DeleteTagConfirmModal, EditTagModal, () => null, Mock.all<ColorGenerator>());
|
|
||||||
|
|
||||||
wrapper = shallow(
|
wrapper = shallow(
|
||||||
<TagCard
|
<TagCard
|
||||||
tag="ssr"
|
tag={tag}
|
||||||
selectedServer={Mock.of<ReachableServer>({ id: '1' })}
|
selectedServer={Mock.of<ReachableServer>({ id: '1' })}
|
||||||
tagStats={tagStats}
|
tagStats={tagStats}
|
||||||
displayed={true}
|
displayed={true}
|
||||||
toggle={() => {}}
|
toggle={() => {}}
|
||||||
/>,
|
/>,
|
||||||
);
|
);
|
||||||
});
|
|
||||||
|
return wrapper;
|
||||||
|
};
|
||||||
|
|
||||||
|
beforeEach(() => createWrapper());
|
||||||
|
|
||||||
afterEach(() => wrapper.unmount());
|
afterEach(() => wrapper.unmount());
|
||||||
afterEach(jest.resetAllMocks);
|
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 links = wrapper.find(Link);
|
||||||
const bullet = wrapper.find(TagBullet);
|
const bullet = wrapper.find(TagBullet);
|
||||||
|
|
||||||
expect(links.at(0).prop('to')).toEqual('/server/1/list-short-urls/1?tag=ssr');
|
expect(links.at(0).prop('to')).toEqual(expectedLink);
|
||||||
expect(bullet.prop('tag')).toEqual('ssr');
|
expect(bullet.prop('tag')).toEqual(tag);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('displays delete modal when delete btn is clicked', () => {
|
it('displays delete modal when delete btn is clicked', () => {
|
||||||
|
|
Loading…
Reference in a new issue