Open all Signal links in app
This commit is contained in:
parent
07968ea42b
commit
60d348e7cb
3 changed files with 90 additions and 7 deletions
|
@ -1,4 +1,4 @@
|
|||
// Copyright 2020-2021 Signal Messenger, LLC
|
||||
// Copyright 2020-2022 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import { assert } from 'chai';
|
||||
|
@ -13,6 +13,7 @@ import {
|
|||
parseCaptchaHref,
|
||||
parseE164FromSignalDotMeHash,
|
||||
parseSignalHttpsLink,
|
||||
rewriteSignalHrefsIfNecessary,
|
||||
} from '../../util/sgnlHref';
|
||||
|
||||
function shouldNeverBeCalled() {
|
||||
|
@ -380,4 +381,62 @@ describe('sgnlHref', () => {
|
|||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('rewriteSignalHrefsIfNecessary', () => {
|
||||
it('rewrites http://signal.group hrefs, making them use HTTPS', () => {
|
||||
assert.strictEqual(
|
||||
rewriteSignalHrefsIfNecessary('http://signal.group/#abc123'),
|
||||
'https://signal.group/#abc123'
|
||||
);
|
||||
});
|
||||
|
||||
it('rewrites http://signal.art hrefs, making them use HTTPS', () => {
|
||||
assert.strictEqual(
|
||||
rewriteSignalHrefsIfNecessary(
|
||||
'http://signal.art/addstickers/#pack_id=abc123'
|
||||
),
|
||||
'https://signal.art/addstickers/#pack_id=abc123'
|
||||
);
|
||||
});
|
||||
|
||||
it('rewrites http://signal.me hrefs, making them use HTTPS', () => {
|
||||
assert.strictEqual(
|
||||
rewriteSignalHrefsIfNecessary('http://signal.me/#p/+18885551234'),
|
||||
'https://signal.me/#p/+18885551234'
|
||||
);
|
||||
});
|
||||
|
||||
it('removes auth if present', () => {
|
||||
assert.strictEqual(
|
||||
rewriteSignalHrefsIfNecessary(
|
||||
'http://user:pass@signal.group/ab?c=d#ef'
|
||||
),
|
||||
'https://signal.group/ab?c=d#ef'
|
||||
);
|
||||
assert.strictEqual(
|
||||
rewriteSignalHrefsIfNecessary(
|
||||
'https://user:pass@signal.group/ab?c=d#ef'
|
||||
),
|
||||
'https://signal.group/ab?c=d#ef'
|
||||
);
|
||||
});
|
||||
|
||||
it('does nothing to other hrefs', () => {
|
||||
[
|
||||
// Normal URLs
|
||||
'http://example.com',
|
||||
// Already HTTPS
|
||||
'https://signal.art/addstickers/#pack_id=abc123',
|
||||
// Different port
|
||||
'http://signal.group:1234/abc?d=e#fg',
|
||||
// Different subdomain
|
||||
'http://subdomain.signal.group/#abcdef',
|
||||
// Different protocol
|
||||
'ftp://signal.group/#abc123',
|
||||
'ftp://user:pass@signal.group/#abc123',
|
||||
].forEach(href => {
|
||||
assert.strictEqual(rewriteSignalHrefsIfNecessary(href), href);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue