fix: update lobste.rs URL syntax

This commit is contained in:
Yarmo Mackenbach 2023-10-07 12:49:35 +02:00
parent a616dcd66d
commit 34ad2d718d
No known key found for this signature in database
GPG key ID: C248C28D432560ED

View file

@ -16,7 +16,7 @@ limitations under the License.
import * as E from '../enums.js' import * as E from '../enums.js'
import { ServiceProvider } from '../serviceProvider.js' import { ServiceProvider } from '../serviceProvider.js'
export const reURI = /^https:\/\/lobste\.rs\/u\/(.*)\/?/ export const reURI = /^https:\/\/lobste\.rs\/(:?~|u\/)(.*)\/?/
/** /**
* @function * @function
@ -33,7 +33,7 @@ export function processURI (uri) {
}, },
profile: { profile: {
display: match[1], display: match[1],
uri, uri: `https://lobste.rs/~${match[1]}`,
qr: null qr: null
}, },
claim: { claim: {
@ -42,11 +42,11 @@ export function processURI (uri) {
}, },
proof: { proof: {
request: { request: {
uri: `https://lobste.rs/u/${match[1]}.json`, uri: `https://lobste.rs/~${match[1]}.json`,
fetcher: E.Fetcher.HTTP, fetcher: E.Fetcher.HTTP,
accessRestriction: E.ProofAccessRestriction.NOCORS, accessRestriction: E.ProofAccessRestriction.NOCORS,
data: { data: {
url: `https://lobste.rs/u/${match[1]}.json`, url: `https://lobste.rs/~${match[1]}.json`,
format: E.ProofFormat.JSON format: E.ProofFormat.JSON
} }
}, },
@ -64,6 +64,10 @@ export function processURI (uri) {
} }
export const tests = [ export const tests = [
{
uri: 'https://lobste.rs/~Alice',
shouldMatch: true
},
{ {
uri: 'https://lobste.rs/u/Alice', uri: 'https://lobste.rs/u/Alice',
shouldMatch: true shouldMatch: true
@ -72,6 +76,10 @@ export const tests = [
uri: 'https://lobste.rs/u/Alice/', uri: 'https://lobste.rs/u/Alice/',
shouldMatch: true shouldMatch: true
}, },
{
uri: 'https://domain.org/~Alice',
shouldMatch: false
},
{ {
uri: 'https://domain.org/u/Alice', uri: 'https://domain.org/u/Alice',
shouldMatch: false shouldMatch: false