mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-10 17:43:51 +00:00
Added support for short URLs with multi-segment slugs
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Mock } from 'ts-mockery';
|
||||
import { ShortUrl } from '../../../src/short-urls/data';
|
||||
import { shortUrlDataFromShortUrl } from '../../../src/short-urls/helpers';
|
||||
import { shortUrlDataFromShortUrl, urlDecodeShortCode, urlEncodeShortCode } from '../../../src/short-urls/helpers';
|
||||
|
||||
describe('helpers', () => {
|
||||
describe('shortUrlDataFromShortUrl', () => {
|
||||
@@ -25,4 +25,24 @@ describe('helpers', () => {
|
||||
expect(shortUrlDataFromShortUrl(shortUrl, settings)).toEqual(expectedInitialState);
|
||||
});
|
||||
});
|
||||
|
||||
describe('urlEncodeShortCode', () => {
|
||||
it.each([
|
||||
['foo', 'foo'],
|
||||
['foo/bar', 'foo__bar'],
|
||||
['foo/bar/baz', 'foo__bar__baz'],
|
||||
])('parses shortCode as expected', (shortCode, result) => {
|
||||
expect(urlEncodeShortCode(shortCode)).toEqual(result);
|
||||
});
|
||||
});
|
||||
|
||||
describe('urlDecodeShortCode', () => {
|
||||
it.each([
|
||||
['foo', 'foo'],
|
||||
['foo__bar', 'foo/bar'],
|
||||
['foo__bar__baz', 'foo/bar/baz'],
|
||||
])('parses shortCode as expected', (shortCode, result) => {
|
||||
expect(urlDecodeShortCode(shortCode)).toEqual(result);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user