Percent-encode URL path when reporting spam
This commit is contained in:
parent
6ddb12cd99
commit
7f0ed2599d
3 changed files with 27 additions and 3 deletions
|
@ -4,7 +4,11 @@
|
|||
import { assert } from 'chai';
|
||||
import { size } from '../../util/iterables';
|
||||
|
||||
import { maybeParseUrl, setUrlSearchParams } from '../../util/url';
|
||||
import {
|
||||
maybeParseUrl,
|
||||
setUrlSearchParams,
|
||||
urlPathFromComponents,
|
||||
} from '../../util/url';
|
||||
|
||||
describe('URL utilities', () => {
|
||||
describe('maybeParseUrl', () => {
|
||||
|
@ -84,4 +88,18 @@ describe('URL utilities', () => {
|
|||
assert.strictEqual(newUrl.search, '?foo=bar');
|
||||
});
|
||||
});
|
||||
|
||||
describe('urlPathFromComponents', () => {
|
||||
it('returns / if no components are provided', () => {
|
||||
assert.strictEqual(urlPathFromComponents([]), '/');
|
||||
});
|
||||
|
||||
it('joins components, percent-encoding them and removing empty components', () => {
|
||||
const components = ['foo', '', '~', 'bar / baz qúx'];
|
||||
assert.strictEqual(
|
||||
urlPathFromComponents(components),
|
||||
'/foo/~/bar%20%2F%20baz%20q%C3%BAx'
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue