diff --git a/package-lock.json b/package-lock.json index ed53d68..b32cc33 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "txtdot", - "version": "1.6.0", + "version": "1.6.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "txtdot", - "version": "1.6.0", + "version": "1.6.1", "license": "MIT", "dependencies": { "@fastify/static": "^6.12.0", diff --git a/package.json b/package.json index 56aab98..9b84838 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "txtdot", - "version": "1.6.0", + "version": "1.6.1", "private": true, "description": "txtdot is an HTTP proxy that parses only text, links and pictures from pages reducing internet bandwidth usage, removing ads and heavy scripts", "main": "dist/app.js", diff --git a/src/routes/browser/proxy.ts b/src/routes/browser/proxy.ts index 20aa0c4..c49f8ed 100644 --- a/src/routes/browser/proxy.ts +++ b/src/routes/browser/proxy.ts @@ -2,11 +2,18 @@ import { FastifyInstance } from 'fastify'; import { IProxySchema, ProxySchema } from '../../types/requests/browser'; import axios from '../../types/axios'; +import isLocalResource from '../../utils/islocal'; +import { LocalResourceError } from '../../errors/main'; + export default async function proxyRoute(fastify: FastifyInstance) { fastify.get( '/proxy', { schema: ProxySchema }, async (request, reply) => { + if (await isLocalResource(new URL(request.query.url))) { + throw new LocalResourceError(); + } + const response = await axios.get(request.query.url); const mime: string | undefined = response.headers['content-type']?.toString();