Skip to content

Commit ebd1ccc

Browse files
authored
chore: validate user input for tv maze urls (#1865)
1 parent ad83ea9 commit ebd1ccc

File tree

16 files changed

+288
-15
lines changed

16 files changed

+288
-15
lines changed

demos/default/pages/api/shows/[...params].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export default async (req, res) => {
1010
const id = params[0]
1111

1212
// Get the data
13-
const fetchRes = await fetch(`https://tvproxy.netlify.app/shows/${id}`)
13+
const fetchRes = await fetch(`https://tvproxy.netlify.app/shows/${Number(id)}`)
1414
const data = await fetchRes.json()
1515

1616
// If show was found, return it

demos/default/pages/api/shows/[id].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default async (req, res) => {
77
const { id } = query
88

99
// Get the data
10-
const fetchRes = await fetch(`https://tvproxy.netlify.app/shows/${id}`)
10+
const fetchRes = await fetch(`https://tvproxy.netlify.app/shows/${Number(id)}`)
1111
const data = await fetchRes.json()
1212

1313
// If show was found, return it

demos/default/pages/getServerSideProps/[id].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const getServerSideProps = async ({ params }) => {
3434
// The ID to render
3535
const { id } = params
3636

37-
const res = await fetch(`https://tvproxy.netlify.app/shows/${id}`)
37+
const res = await fetch(`https://tvproxy.netlify.app/shows/${Number(id)}`)
3838
const data = await res.json()
3939

4040
// Set error code if show item could not be found

demos/default/pages/getServerSideProps/all/[[...slug]].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export const getServerSideProps = async ({ params }) => {
3434
// The ID to render
3535
const { slug } = params
3636

37-
const res = await fetch(`https://tvproxy.netlify.app/shows/${slug[0]}`)
37+
const res = await fetch(`https://tvproxy.netlify.app/shows/${Number(slug[0])}`)
3838
const data = await res.json()
3939

4040
// Set error code if show item could not be found

demos/default/pages/getStaticProps/[id].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function getStaticProps({ params }) {
2828
// The ID to render
2929
const { id } = params
3030

31-
const res = await fetch(`https://tvproxy.netlify.app/shows/${id}`)
31+
const res = await fetch(`https://tvproxy.netlify.app/shows/${Number(id)}`)
3232
const data = await res.json()
3333
const time = new Date().toLocaleTimeString()
3434

demos/default/pages/getStaticProps/withFallback/[...slug].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export async function getStaticProps({ params }) {
4242
const { slug } = params
4343
const id = slug[slug.length - 1]
4444

45-
const res = await fetch(`https://tvproxy.netlify.app/shows/${id}`)
45+
const res = await fetch(`https://tvproxy.netlify.app/shows/${Number(id)}`)
4646
const data = await res.json()
4747
const time = new Date().toLocaleTimeString()
4848

demos/default/pages/getStaticProps/withFallback/[id].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function getStaticProps({ params }) {
4141
// The ID to render
4242
const { id } = params
4343

44-
const res = await fetch(`https://tvproxy.netlify.app/shows/${id}`)
44+
const res = await fetch(`https://tvproxy.netlify.app/shows/${Number(id)}`)
4545
const data = await res.json()
4646
const time = new Date().toLocaleTimeString()
4747

demos/default/pages/getStaticProps/withFallbackBlocking/[id].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export async function getStaticProps({ params }) {
3030
// The ID to render
3131
const { id } = params
3232

33-
const res = await fetch(`https://tvproxy.netlify.app/shows/${id}`)
33+
const res = await fetch(`https://tvproxy.netlify.app/shows/${Number(id)}`)
3434
const data = await res.json()
3535
const time = new Date().toLocaleTimeString()
3636

demos/default/pages/getStaticProps/withRevalidate/[id].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function getStaticProps({ params }) {
2929
// The ID to render
3030
const { id } = params
3131

32-
const res = await fetch(`https://tvproxy.netlify.app/shows/${id}`)
32+
const res = await fetch(`https://tvproxy.netlify.app/shows/${Number(id)}`)
3333
const data = await res.json()
3434
const time = new Date().toLocaleTimeString()
3535

demos/default/pages/getStaticProps/withRevalidate/withFallback/[id].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export async function getStaticProps({ params }) {
4242
// The ID to render
4343
const { id } = params
4444

45-
const res = await fetch(`https://tvproxy.netlify.app/shows/${id}`)
45+
const res = await fetch(`https://tvproxy.netlify.app/shows/${Number(id)}`)
4646
const data = await res.json()
4747
const time = new Date().toLocaleTimeString()
4848

demos/default/pages/getStaticProps/withRevalidate/withFallbackBlocking/[id].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function getStaticProps({ params }) {
2929
// The ID to render
3030
const { id } = params
3131

32-
const res = await fetch(`https://tvproxy.netlify.app/shows/${id}`)
32+
const res = await fetch(`https://tvproxy.netlify.app/shows/${Number(id)}`)
3333
const data = await res.json()
3434
const time = new Date().toLocaleTimeString()
3535

demos/default/pages/shows/[...params].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ CatchAll.getInitialProps = async ({ res: req, query }) => {
4747
const id = params[0]
4848

4949
// Get the data
50-
const res = await fetch(`https://tvproxy.netlify.app/shows/${id}`)
50+
const res = await fetch(`https://tvproxy.netlify.app/shows/${Number(id)}`)
5151
const data = await res.json()
5252

5353
// Set error code if show item could not be found

demos/default/pages/shows/[id].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Show.getInitialProps = async ({ res: req, query }) => {
3535
const { id } = query
3636

3737
// Get the data
38-
const res = await fetch(`https://tvproxy.netlify.app/shows/${id}`)
38+
const res = await fetch(`https://tvproxy.netlify.app/shows/${Number(id)}`)
3939
const data = await res.json()
4040

4141
// Set error code if show item could not be found

demos/middleware/pages/shows/[id].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export const getServerSideProps = async ({ params, req }) => {
3333
// The ID to render
3434
const { id } = params
3535
console.log(req.headers)
36-
const res = await fetch(`https://tvproxy.netlify.app/shows/${id}`)
36+
const res = await fetch(`https://tvproxy.netlify.app/shows/${Number(id)}`)
3737
const data = await res.json()
3838

3939
// Set error code if show item could not be found

demos/middleware/pages/shows/static/[id].js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export async function getStaticProps({ params }) {
4040
// The ID to render
4141
const { id } = params
4242

43-
const res = await fetch(`https://tvproxy.netlify.app/shows/${id}`)
43+
const res = await fetch(`https://tvproxy.netlify.app/shows/${Number(id)}`)
4444
const data = await res.json()
4545

4646
return {

0 commit comments

Comments
 (0)