Adjust fix suggestions
This commit is contained in:
parent
b57fbd8b6d
commit
e2fb5de595
13
src/Link.js
13
src/Link.js
@ -73,14 +73,13 @@ export const LinkKind = createEnum(
|
|||||||
|
|
||||||
export function tryFixUrl(fragment) {
|
export function tryFixUrl(fragment) {
|
||||||
const attempts = [];
|
const attempts = [];
|
||||||
if (fragment.startsWith('#') && !fragment.startsWith('#/')) {
|
const afterHash = fragment.substring(fragment.startsWith("#/") ? 2 : 1);
|
||||||
if (!fragment.match(/^#[@$!]/)) {
|
attempts.push('#/@' + afterHash); // #room => #/@room
|
||||||
attempts.push('#/' + fragment); // #room => #/#room
|
attempts.push('#/#' + afterHash); // #@room => #/@room
|
||||||
}
|
attempts.push('#/!' + afterHash); // #@room => #/@room
|
||||||
attempts.push('#/' + fragment.substring(1)); // #@room => #/@room
|
|
||||||
}
|
|
||||||
const validAttempts = [];
|
const validAttempts = [];
|
||||||
for (const attempt of attempts) {
|
for (const attempt of [...new Set(attempts)]) {
|
||||||
const link = Link.parse(attempt);
|
const link = Link.parse(attempt);
|
||||||
if (link) {
|
if (link) {
|
||||||
validAttempts.push({ url: attempt, link });
|
validAttempts.push({ url: attempt, link });
|
||||||
|
Loading…
Reference in New Issue
Block a user