Skip to content

Commit d12598b

Browse files
Copilotunnoq
andauthored
fix(standard-server): change SHORTABLE_ORIGIN from orpc:// to http:// for Android WebView compatibility (#1295)
- [x] Change `SHORTABLE_ORIGIN` from `'orpc://localhost'` to `'http://orpc'` in `/packages/standard-server-peer/src/codec.ts` - [x] Update `SHORTABLE_ORIGIN_MATCHER` regex to match the new origin pattern - [x] Update comment in SerializedRequestPayload interface to reflect new origin - [x] Update tests in `/packages/standard-server-peer/src/codec.test.ts` to use the new `http://orpc` scheme - [x] Update `/packages/client/src/adapters/message-port/rpc-link.ts` to use `http://orpc` - [x] Update `/packages/client/src/adapters/websocket/rpc-link.ts` to use `http://orpc` - [x] Update all related test files to use `http://orpc`: - `/packages/client/src/adapters/message-port/rpc-link.test.ts` - `/packages/client/src/adapters/websocket/rpc-link.test.ts` - `/packages/server/src/adapters/websocket/rpc-handler.test.ts` - `/packages/server/src/adapters/crossws/rpc-handler.test.ts` - `/packages/server/src/adapters/bun-ws/rpc-handler.test.ts` - `/packages/server/src/adapters/message-port/rpc-handler.test.ts` - `/packages/server/src/adapters/ws/rpc-handler.test.ts` - [x] Run tests to verify changes work correctly (all 4631 tests passed) - [x] Run code review (no issues found) - [x] Run security checks (no vulnerabilities found) <!-- START COPILOT CODING AGENT SUFFIX --> <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > On codec.ts, Please change SHORTABLE_ORIGIN to http://orpc becaues currently orpc:// schema is not allowed in adroid webview - please fix it and update according tests </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💬 We'd love your input! Share your thoughts on Copilot coding agent in our [2 minute survey](https://gh.io/copilot-coding-agent-survey). --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: unnoq <64189902+unnoq@users.noreply.github.com>
1 parent 059b949 commit d12598b

File tree

11 files changed

+26
-26
lines changed

11 files changed

+26
-26
lines changed

packages/client/src/adapters/message-port/rpc-link.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ describe('rpcLink', () => {
4040

4141
expect(id).toBeTypeOf('string')
4242
expect(payload).toEqual({
43-
url: new URL('orpc://localhost/ping'),
43+
url: new URL('http://orpc/ping'),
4444
body: { json: 'input' },
4545
headers: {},
4646
method: 'POST',
@@ -60,7 +60,7 @@ describe('rpcLink', () => {
6060

6161
expect(id).toBeTypeOf('string')
6262
expect(payload).toEqual({
63-
url: new URL('orpc://localhost/ping'),
63+
url: new URL('http://orpc/ping'),
6464
body: expect.any(FormData),
6565
headers: expect.any(Object),
6666
method: 'POST',
@@ -86,15 +86,15 @@ describe('rpcLink', () => {
8686

8787
expect(transfer).toHaveBeenCalledTimes(1)
8888
expect(transfer).toHaveBeenCalledWith([id, type, expect.objectContaining({
89-
url: new URL('orpc://localhost/ping'),
89+
url: new URL('http://orpc/ping'),
9090
body: { json: expect.toBeOneOf([array]) },
9191
headers: {},
9292
method: 'POST',
9393
})], expect.toBeOneOf([clientPort]))
9494

9595
expect(id).toBeTypeOf('string')
9696
expect(payload).toEqual({
97-
url: new URL('orpc://localhost/ping'),
97+
url: new URL('http://orpc/ping'),
9898
body: { json: expect.toSatisfy(v => v !== array && v instanceof Uint8Array && v.byteLength === 3) },
9999
headers: {},
100100
method: 'POST',

packages/client/src/adapters/message-port/rpc-link.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ export interface RPCLinkOptions<T extends ClientContext>
1616
export class RPCLink<T extends ClientContext> extends StandardRPCLink<T> {
1717
constructor(options: RPCLinkOptions<T>) {
1818
const linkClient = new LinkMessagePortClient(options)
19-
super(linkClient, { ...options, url: 'orpc://localhost' })
19+
super(linkClient, { ...options, url: 'http://orpc' })
2020
}
2121
}

packages/client/src/adapters/websocket/rpc-link.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ describe('rpcLink', () => {
3636

3737
expect(id).toBeTypeOf('string')
3838
expect(payload).toEqual({
39-
url: new URL('orpc://localhost/ping'),
39+
url: new URL('http://orpc/ping'),
4040
body: { json: 'input' },
4141
headers: {},
4242
method: 'POST',
@@ -56,7 +56,7 @@ describe('rpcLink', () => {
5656

5757
expect(id).toBeTypeOf('string')
5858
expect(payload).toEqual({
59-
url: new URL('orpc://localhost/ping'),
59+
url: new URL('http://orpc/ping'),
6060
body: { json: 'input' },
6161
headers: {},
6262
method: 'POST',

packages/client/src/adapters/websocket/rpc-link.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ export class RPCLink<T extends ClientContext> extends StandardRPCLink<T> {
1717
constructor(options: RPCLinkOptions<T>) {
1818
const linkClient = new LinkWebsocketClient(options)
1919

20-
super(linkClient, { ...options, url: 'orpc://localhost' })
20+
super(linkClient, { ...options, url: 'http://orpc' })
2121
}
2222
}

packages/server/src/adapters/bun-ws/rpc-handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('rpcHandler', async () => {
2323
}
2424

2525
const string_request_message = await encodeRequestMessage('19', MessageType.REQUEST, {
26-
url: new URL('orpc://localhost/ping'),
26+
url: new URL('http://orpc/ping'),
2727
body: { json: 'input' },
2828
headers: {},
2929
method: 'POST',

packages/server/src/adapters/crossws/rpc-handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('rpcHandler', async () => {
2424

2525
const ping_request_message = {
2626
rawData: await encodeRequestMessage('19', MessageType.REQUEST, {
27-
url: new URL('orpc://localhost/ping'),
27+
url: new URL('http://orpc/ping'),
2828
body: { json: 'input' },
2929
headers: {},
3030
method: 'POST',

packages/server/src/adapters/message-port/rpc-handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('rpcHandler', async () => {
4444
})
4545

4646
const string_request_message = await encodeRequestMessage('19', MessageType.REQUEST, {
47-
url: new URL('orpc://localhost/ping'),
47+
url: new URL('http://orpc/ping'),
4848
body: { json: 'input' },
4949
headers: {},
5050
method: 'POST',

packages/server/src/adapters/websocket/rpc-handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('rpcHandler', async () => {
3535

3636
const string_request_message = {
3737
data: await encodeRequestMessage('19', MessageType.REQUEST, {
38-
url: new URL('orpc://localhost/ping'),
38+
url: new URL('http://orpc/ping'),
3939
body: { json: 'input' },
4040
headers: {},
4141
method: 'POST',

packages/server/src/adapters/ws/rpc-handler.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ describe('rpcHandler', async () => {
3535

3636
const string_request_message = {
3737
data: await encodeRequestMessage('19', MessageType.REQUEST, {
38-
url: new URL('orpc://localhost/ping'),
38+
url: new URL('http://orpc/ping'),
3939
body: { json: 'input' },
4040
headers: {},
4141
method: 'POST',

packages/standard-server-peer/src/codec.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('serializeRequestMessage & deserializeRequestMessage', () => {
1212
it('should serialize and deserialize a basic POST request', () => {
1313
const id = 'req-123'
1414
const payload: RequestMessageMap[MessageType.REQUEST] = {
15-
url: new URL('orpc://localhost/api/users'),
15+
url: new URL('http://orpc/api/users'),
1616
method: 'POST',
1717
headers: { 'content-type': 'application/json' },
1818
body: { name: 'John' },
@@ -34,7 +34,7 @@ describe('serializeRequestMessage & deserializeRequestMessage', () => {
3434

3535
expect(decodedId).toBe(id)
3636
expect(decodedType).toBe(MessageType.REQUEST)
37-
expect(decodedPayload.url.toString()).toBe('orpc://localhost/api/users')
37+
expect(decodedPayload.url.toString()).toBe('http://orpc/api/users')
3838
expect(decodedPayload.method).toBe('POST')
3939
expect(decodedPayload.headers).toEqual({ 'content-type': 'application/json' })
4040
expect(decodedPayload.body).toEqual({ name: 'John' })
@@ -75,7 +75,7 @@ describe('serializeRequestMessage & deserializeRequestMessage', () => {
7575
const blobData = new Blob(['test content'], { type: 'text/plain' })
7676

7777
const payload: RequestMessageMap[MessageType.REQUEST] = {
78-
url: new URL('orpc://localhost/upload'),
78+
url: new URL('http://orpc/upload'),
7979
method: 'POST',
8080
headers: { 'content-type': 'text/plain' },
8181
body: blobData,
@@ -140,7 +140,7 @@ describe('serializeRequestMessage & deserializeRequestMessage', () => {
140140
it('should omit empty headers and default POST method', () => {
141141
const id = 'req-minimal'
142142
const payload: RequestMessageMap[MessageType.REQUEST] = {
143-
url: new URL('orpc://localhost/test'),
143+
url: new URL('http://orpc/test'),
144144
method: 'POST',
145145
headers: {},
146146
body: 'data',
@@ -337,12 +337,12 @@ describe('encode/decode request message', () => {
337337
})
338338

339339
describe.each([
340-
['GET', new URL('orpc://localhost/api/v1/users/1?a=1&b=2'), {}],
341-
['GET', new URL('orpc:///localhost/api/v1/users/1?a=1&b=2'), {}],
342-
['GET', new URL('orpc://example.com/api/v1/users/1?a=1&b=2'), {}],
343-
['GET', new URL('orpc:///example.com/api/v1/users/1?a=1&b=2'), {}],
344-
['GET', new URL('orpc:/api/v1/users/1?a=1&b=2'), {}],
345-
['GET', new URL('orpc://api/v1/users/1?a=1&b=2'), {}],
340+
['GET', new URL('http://orpc/api/v1/users/1?a=1&b=2'), {}],
341+
['GET', new URL('http:///orpc/api/v1/users/1?a=1&b=2'), {}],
342+
['GET', new URL('http://example.com/api/v1/users/1?a=1&b=2'), {}],
343+
['GET', new URL('http:///example.com/api/v1/users/1?a=1&b=2'), {}],
344+
['GET', new URL('http:/api/v1/users/1?a=1&b=2'), {}],
345+
['GET', new URL('http://api/v1/users/1?a=1&b=2'), {}],
346346
['GET', new URL('https://example.com/api/v1/users/1?a=1&b=2'), {}],
347347
['POST', new URL('https://example.com/api/v1/users/1'), { 'x-custom-header': 'value' }],
348348
['DELETE', new URL('https://example.com/api/v1/users/1'), { }],

0 commit comments

Comments
 (0)