Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
dholms committed Oct 20, 2023
1 parent c99ec64 commit 6aa9637
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion interop-test-files/syntax/did_syntax_valid.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ did:onion:2gzyxa5ihm7nsggfxnu52rck2vv4rvmdlkiu3zzui5du4xyclen53wid
did:example:123456789abcdefghi
did:plc:7iza6de2dwap2sbkpav7c6c6
did:web:example.com
did:web:127.0.0.1%3A1234
did:web:localhost%3A1234
did:key:zQ3shZc2QzApp2oymGvQbzP8eKheVshBHbU4ZYjeXqwSKEn6N
did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a
2 changes: 1 addition & 1 deletion packages/identity/src/did/web-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export class DidWebResolver extends BaseResolver {
}

const url = new URL(`https://${path}`)
if (url.hostname === '127.0.0.1' || url.hostname === '127.0.0.1') {
if (url.hostname === 'localhost' || url.hostname === '127.0.0.1') {
url.protocol = 'http'
}

Expand Down
2 changes: 1 addition & 1 deletion packages/pds/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const envToCfg = (env: ServerEnvironment): ServerConfig => {
const port = env.port ?? 2583
const hostname = env.hostname ?? '127.0.0.1'
const publicUrl =
hostname === '127.0.0.1'
hostname === '127.0.0.1' || hostname === 'localhost'
? `http://127.0.0.1:${port}`
: `https://${hostname}`
const did = env.serviceDid ?? `did:web:${hostname}`
Expand Down
2 changes: 1 addition & 1 deletion packages/pds/tests/_util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export const forSnapshot = (obj: unknown) => {
const [, did, cid] = match
return str.replace(did, take(users, did)).replace(cid, take(cids, cid))
}
if (str.startsWith('127.0.0.1-')) {
if (str.startsWith('127.0.0.1-') || str.startsWith('localhost')) {
return 'invite-code'
}
if (str.match(/^\d+::pds-public-url-/)) {
Expand Down
2 changes: 1 addition & 1 deletion packages/pds/tests/handle-validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('handle validation', () => {
expect(isValidTld('atproto.local')).toBe(false)
expect(isValidTld('atproto.arpa')).toBe(false)
expect(isValidTld('atproto.invalid')).toBe(false)
expect(isValidTld('atproto.127.0.0.1')).toBe(false)
expect(isValidTld('atproto.localhost')).toBe(false)
expect(isValidTld('atproto.onion')).toBe(false)
expect(isValidTld('atproto.internal')).toBe(false)
})
Expand Down
2 changes: 1 addition & 1 deletion packages/syntax/src/handle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const DISALLOWED_TLDS = [
'.local',
'.arpa',
'.invalid',
'.127.0.0.1',
'.localhost',
'.internal',
'.example',
'.alt',
Expand Down
76 changes: 38 additions & 38 deletions packages/syntax/tests/aturi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,102 +137,102 @@ describe('At Uris', () => {
'#hash',
],

['did:web:127.0.0.1%3A1234', 'did:web:127.0.0.1%3A1234', '', '', ''],
['at://did:web:127.0.0.1%3A1234', 'did:web:127.0.0.1%3A1234', '', '', ''],
['did:web:localhost%3A1234', 'did:web:localhost%3A1234', '', '', ''],
['at://did:web:localhost%3A1234', 'did:web:localhost%3A1234', '', '', ''],
[
'at://did:web:127.0.0.1%3A1234/',
'did:web:127.0.0.1%3A1234',
'at://did:web:localhost%3A1234/',
'did:web:localhost%3A1234',
'/',
'',
'',
],
[
'at://did:web:127.0.0.1%3A1234/foo',
'did:web:127.0.0.1%3A1234',
'at://did:web:localhost%3A1234/foo',
'did:web:localhost%3A1234',
'/foo',
'',
'',
],
[
'at://did:web:127.0.0.1%3A1234/foo/',
'did:web:127.0.0.1%3A1234',
'at://did:web:localhost%3A1234/foo/',
'did:web:localhost%3A1234',
'/foo/',
'',
'',
],
[
'at://did:web:127.0.0.1%3A1234/foo/bar',
'did:web:127.0.0.1%3A1234',
'at://did:web:localhost%3A1234/foo/bar',
'did:web:localhost%3A1234',
'/foo/bar',
'',
'',
],
[
'at://did:web:127.0.0.1%3A1234?foo=bar',
'did:web:127.0.0.1%3A1234',
'at://did:web:localhost%3A1234?foo=bar',
'did:web:localhost%3A1234',
'',
'foo=bar',
'',
],
[
'at://did:web:127.0.0.1%3A1234?foo=bar&baz=buux',
'did:web:127.0.0.1%3A1234',
'at://did:web:localhost%3A1234?foo=bar&baz=buux',
'did:web:localhost%3A1234',
'',
'foo=bar&baz=buux',
'',
],
[
'at://did:web:127.0.0.1%3A1234/?foo=bar',
'did:web:127.0.0.1%3A1234',
'at://did:web:localhost%3A1234/?foo=bar',
'did:web:localhost%3A1234',
'/',
'foo=bar',
'',
],
[
'at://did:web:127.0.0.1%3A1234/foo?foo=bar',
'did:web:127.0.0.1%3A1234',
'at://did:web:localhost%3A1234/foo?foo=bar',
'did:web:localhost%3A1234',
'/foo',
'foo=bar',
'',
],
[
'at://did:web:127.0.0.1%3A1234/foo/?foo=bar',
'did:web:127.0.0.1%3A1234',
'at://did:web:localhost%3A1234/foo/?foo=bar',
'did:web:localhost%3A1234',
'/foo/',
'foo=bar',
'',
],
[
'at://did:web:127.0.0.1%3A1234#hash',
'did:web:127.0.0.1%3A1234',
'at://did:web:localhost%3A1234#hash',
'did:web:localhost%3A1234',
'',
'',
'#hash',
],
[
'at://did:web:127.0.0.1%3A1234/#hash',
'did:web:127.0.0.1%3A1234',
'at://did:web:localhost%3A1234/#hash',
'did:web:localhost%3A1234',
'/',
'',
'#hash',
],
[
'at://did:web:127.0.0.1%3A1234/foo#hash',
'did:web:127.0.0.1%3A1234',
'at://did:web:localhost%3A1234/foo#hash',
'did:web:localhost%3A1234',
'/foo',
'',
'#hash',
],
[
'at://did:web:127.0.0.1%3A1234/foo/#hash',
'did:web:127.0.0.1%3A1234',
'at://did:web:localhost%3A1234/foo/#hash',
'did:web:localhost%3A1234',
'/foo/',
'',
'#hash',
],
[
'at://did:web:127.0.0.1%3A1234?foo=bar#hash',
'did:web:127.0.0.1%3A1234',
'at://did:web:localhost%3A1234?foo=bar#hash',
'did:web:localhost%3A1234',
'',
'foo=bar',
'#hash',
Expand Down Expand Up @@ -281,8 +281,8 @@ describe('At Uris', () => {

urip.host = 'bar.com'
expect(urip.toString()).toBe('at://bar.com/')
urip.host = 'did:web:127.0.0.1%3A1234'
expect(urip.toString()).toBe('at://did:web:127.0.0.1%3A1234/')
urip.host = 'did:web:localhost%3A1234'
expect(urip.toString()).toBe('at://did:web:localhost%3A1234/')
urip.host = 'foo.com'

urip.pathname = '/'
Expand Down Expand Up @@ -337,12 +337,12 @@ describe('At Uris', () => {
['?foo=bar#hash', '', 'foo=bar', '#hash'],
]
const BASES: string[] = [
'did:web:127.0.0.1%3A1234',
'at://did:web:127.0.0.1%3A1234',
'at://did:web:127.0.0.1%3A1234/foo/bar?foo=bar&baz=buux#hash',
'did:web:127.0.0.1%3A1234',
'at://did:web:127.0.0.1%3A1234',
'at://did:web:127.0.0.1%3A1234/foo/bar?foo=bar&baz=buux#hash',
'did:web:localhost%3A1234',
'at://did:web:localhost%3A1234',
'at://did:web:localhost%3A1234/foo/bar?foo=bar&baz=buux#hash',
'did:web:localhost%3A1234',
'at://did:web:localhost%3A1234',
'at://did:web:localhost%3A1234/foo/bar?foo=bar&baz=buux#hash',
]

for (const base of BASES) {
Expand Down
2 changes: 1 addition & 1 deletion packages/syntax/tests/did.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('DID permissive validation', () => {
expectValid('did:example:123456789abcdefghi')
expectValid('did:plc:7iza6de2dwap2sbkpav7c6c6')
expectValid('did:web:example.com')
expectValid('did:web:127.0.0.1%3A1234')
expectValid('did:web:localhost%3A1234')
expectValid('did:key:zQ3shZc2QzApp2oymGvQbzP8eKheVshBHbU4ZYjeXqwSKEn6N')
expectValid('did:ethr:0xb9c5714089478a327f09197987f16f9e5d936e8a')
})
Expand Down

0 comments on commit 6aa9637

Please sign in to comment.