Skip to content

Commit 2ba37fc

Browse files
committed
make simpler
1 parent 9b776f7 commit 2ba37fc

File tree

17 files changed

+17
-34
lines changed

17 files changed

+17
-34
lines changed

exercises/02.init/02.solution.params/src/auth.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import { EPIC_ME_AUTH_SERVER_URL } from './client.ts'
22

33
export function handleUnauthorized(request: Request) {
4-
const url = new URL(request.url)
5-
url.pathname = '/.well-known/oauth-protected-resource/mcp'
4+
const url = new URL('/.well-known/oauth-protected-resource/mcp', request.url)
65

76
return new Response('Unauthorized', {
87
status: 401,

exercises/03.auth-info/01.problem.introspect/src/auth.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ import { EPIC_ME_AUTH_SERVER_URL } from './client.ts'
2525
// 🐨 return the AuthInfo (💰 the sub is the userId)
2626

2727
export function handleUnauthorized(request: Request) {
28-
const url = new URL(request.url)
29-
url.pathname = '/.well-known/oauth-protected-resource/mcp'
28+
const url = new URL('/.well-known/oauth-protected-resource/mcp', request.url)
3029

3130
return new Response('Unauthorized', {
3231
status: 401,

exercises/03.auth-info/01.solution.introspect/src/auth.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ export async function resolveAuthInfo(
4242
}
4343

4444
export function handleUnauthorized(request: Request) {
45-
const url = new URL(request.url)
46-
url.pathname = '/.well-known/oauth-protected-resource/mcp'
45+
const url = new URL('/.well-known/oauth-protected-resource/mcp', request.url)
4746

4847
return new Response('Unauthorized', {
4948
status: 401,

exercises/03.auth-info/02.problem.error/src/auth.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ export async function resolveAuthInfo(
4444
export function handleUnauthorized(request: Request) {
4545
// 🐨 make a "hasAuthHeader" variable that's true if the request has an Authorization header
4646

47-
const url = new URL(request.url)
48-
url.pathname = '/.well-known/oauth-protected-resource/mcp'
47+
const url = new URL('/.well-known/oauth-protected-resource/mcp', request.url)
4948

5049
return new Response('Unauthorized', {
5150
status: 401,

exercises/03.auth-info/02.solution.error/src/auth.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ export async function resolveAuthInfo(
4444
export function handleUnauthorized(request: Request) {
4545
const hasAuthHeader = request.headers.has('authorization')
4646

47-
const url = new URL(request.url)
48-
url.pathname = '/.well-known/oauth-protected-resource/mcp'
47+
const url = new URL('/.well-known/oauth-protected-resource/mcp', request.url)
4948

5049
return new Response('Unauthorized', {
5150
status: 401,

exercises/03.auth-info/03.problem.active/src/auth.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ export async function resolveAuthInfo(
4848
export function handleUnauthorized(request: Request) {
4949
const hasAuthHeader = request.headers.has('authorization')
5050

51-
const url = new URL(request.url)
52-
url.pathname = '/.well-known/oauth-protected-resource/mcp'
51+
const url = new URL('/.well-known/oauth-protected-resource/mcp', request.url)
5352
return new Response('Unauthorized', {
5453
status: 401,
5554
headers: {

exercises/03.auth-info/03.solution.active/src/auth.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ export async function resolveAuthInfo(
5252
export function handleUnauthorized(request: Request) {
5353
const hasAuthHeader = request.headers.has('authorization')
5454

55-
const url = new URL(request.url)
56-
url.pathname = '/.well-known/oauth-protected-resource/mcp'
55+
const url = new URL('/.well-known/oauth-protected-resource/mcp', request.url)
5756
return new Response('Unauthorized', {
5857
status: 401,
5958
headers: {

exercises/04.user/01.problem.token/src/auth.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ export async function resolveAuthInfo(
5252
export function handleUnauthorized(request: Request) {
5353
const hasAuthHeader = request.headers.has('authorization')
5454

55-
const url = new URL(request.url)
56-
url.pathname = '/.well-known/oauth-protected-resource/mcp'
55+
const url = new URL('/.well-known/oauth-protected-resource/mcp', request.url)
5756
return new Response('Unauthorized', {
5857
status: 401,
5958
headers: {

exercises/04.user/01.solution.token/src/auth.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ export async function resolveAuthInfo(
5252
export function handleUnauthorized(request: Request) {
5353
const hasAuthHeader = request.headers.has('authorization')
5454

55-
const url = new URL(request.url)
56-
url.pathname = '/.well-known/oauth-protected-resource/mcp'
55+
const url = new URL('/.well-known/oauth-protected-resource/mcp', request.url)
5756
return new Response('Unauthorized', {
5857
status: 401,
5958
headers: {

exercises/04.user/02.problem.user/src/auth.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,7 @@ export async function resolveAuthInfo(
5252
export function handleUnauthorized(request: Request) {
5353
const hasAuthHeader = request.headers.has('authorization')
5454

55-
const url = new URL(request.url)
56-
url.pathname = '/.well-known/oauth-protected-resource/mcp'
55+
const url = new URL('/.well-known/oauth-protected-resource/mcp', request.url)
5756
return new Response('Unauthorized', {
5857
status: 401,
5958
headers: {

0 commit comments

Comments
 (0)