Spaces:
Build error
Build error
fix: uri encoding
Browse files
backend/functions/package-lock.json
CHANGED
|
@@ -21,7 +21,7 @@
|
|
| 21 |
"dayjs": "^1.11.9",
|
| 22 |
"express": "^4.19.2",
|
| 23 |
"firebase-admin": "^12.1.0",
|
| 24 |
-
"firebase-functions": "^
|
| 25 |
"htmlparser2": "^9.0.0",
|
| 26 |
"jose": "^5.1.0",
|
| 27 |
"langdetect": "^0.2.1",
|
|
@@ -5503,9 +5503,10 @@
|
|
| 5503 |
}
|
| 5504 |
},
|
| 5505 |
"node_modules/firebase-functions": {
|
| 5506 |
-
"version": "
|
| 5507 |
-
"resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-
|
| 5508 |
-
"integrity": "sha512-
|
|
|
|
| 5509 |
"dependencies": {
|
| 5510 |
"@types/cors": "^2.8.5",
|
| 5511 |
"@types/express": "4.17.3",
|
|
@@ -5520,7 +5521,7 @@
|
|
| 5520 |
"node": ">=14.10.0"
|
| 5521 |
},
|
| 5522 |
"peerDependencies": {
|
| 5523 |
-
"firebase-admin": "^
|
| 5524 |
}
|
| 5525 |
},
|
| 5526 |
"node_modules/firebase-functions-test": {
|
|
|
|
| 21 |
"dayjs": "^1.11.9",
|
| 22 |
"express": "^4.19.2",
|
| 23 |
"firebase-admin": "^12.1.0",
|
| 24 |
+
"firebase-functions": "^6.0.1",
|
| 25 |
"htmlparser2": "^9.0.0",
|
| 26 |
"jose": "^5.1.0",
|
| 27 |
"langdetect": "^0.2.1",
|
|
|
|
| 5503 |
}
|
| 5504 |
},
|
| 5505 |
"node_modules/firebase-functions": {
|
| 5506 |
+
"version": "6.0.1",
|
| 5507 |
+
"resolved": "https://registry.npmjs.org/firebase-functions/-/firebase-functions-6.0.1.tgz",
|
| 5508 |
+
"integrity": "sha512-0rIpTU6dnLRvP3IK+okn1FDjoqjzShm0/S+i4OMY7JFu/HJoyJ1JNkrT4KjECy1/mCHK49KsmH8iYE0rzrglHg==",
|
| 5509 |
+
"license": "MIT",
|
| 5510 |
"dependencies": {
|
| 5511 |
"@types/cors": "^2.8.5",
|
| 5512 |
"@types/express": "4.17.3",
|
|
|
|
| 5521 |
"node": ">=14.10.0"
|
| 5522 |
},
|
| 5523 |
"peerDependencies": {
|
| 5524 |
+
"firebase-admin": "^11.10.0 || ^12.0.0"
|
| 5525 |
}
|
| 5526 |
},
|
| 5527 |
"node_modules/firebase-functions-test": {
|
backend/functions/package.json
CHANGED
|
@@ -41,7 +41,7 @@
|
|
| 41 |
"dayjs": "^1.11.9",
|
| 42 |
"express": "^4.19.2",
|
| 43 |
"firebase-admin": "^12.1.0",
|
| 44 |
-
"firebase-functions": "^
|
| 45 |
"htmlparser2": "^9.0.0",
|
| 46 |
"jose": "^5.1.0",
|
| 47 |
"langdetect": "^0.2.1",
|
|
|
|
| 41 |
"dayjs": "^1.11.9",
|
| 42 |
"express": "^4.19.2",
|
| 43 |
"firebase-admin": "^12.1.0",
|
| 44 |
+
"firebase-functions": "^6.0.1",
|
| 45 |
"htmlparser2": "^9.0.0",
|
| 46 |
"jose": "^5.1.0",
|
| 47 |
"langdetect": "^0.2.1",
|
backend/functions/src/cloud-functions/crawler.ts
CHANGED
|
@@ -156,7 +156,7 @@ export class CrawlerHost extends RPCHost {
|
|
| 156 |
let chargeAmount = 0;
|
| 157 |
const crawlerOptions = ctx.req.method === 'GET' ? crawlerOptionsHeaderOnly : crawlerOptionsParamsAllowed;
|
| 158 |
|
| 159 |
-
const targetUrl = await this.getTargetUrl(ctx.req.url, crawlerOptions);
|
| 160 |
if (!targetUrl) {
|
| 161 |
const latestUser = uid ? await auth.assertUser() : undefined;
|
| 162 |
if (!ctx.req.accepts('text/plain') && (ctx.req.accepts('text/json') || ctx.req.accepts('application/json'))) {
|
|
@@ -592,11 +592,11 @@ export class CrawlerHost extends RPCHost {
|
|
| 592 |
|
| 593 |
assignChargeAmount(formatted: FormattedPage) {
|
| 594 |
if (!formatted) {
|
| 595 |
-
return
|
| 596 |
}
|
| 597 |
|
| 598 |
const textContent = formatted?.content || formatted?.description || formatted?.text || formatted?.html;
|
| 599 |
-
let amount;
|
| 600 |
do {
|
| 601 |
if (typeof textContent === 'string') {
|
| 602 |
amount = estimateToken(textContent);
|
|
|
|
| 156 |
let chargeAmount = 0;
|
| 157 |
const crawlerOptions = ctx.req.method === 'GET' ? crawlerOptionsHeaderOnly : crawlerOptionsParamsAllowed;
|
| 158 |
|
| 159 |
+
const targetUrl = await this.getTargetUrl(decodeURIComponent(ctx.req.url), crawlerOptions);
|
| 160 |
if (!targetUrl) {
|
| 161 |
const latestUser = uid ? await auth.assertUser() : undefined;
|
| 162 |
if (!ctx.req.accepts('text/plain') && (ctx.req.accepts('text/json') || ctx.req.accepts('application/json'))) {
|
|
|
|
| 592 |
|
| 593 |
assignChargeAmount(formatted: FormattedPage) {
|
| 594 |
if (!formatted) {
|
| 595 |
+
return 0;
|
| 596 |
}
|
| 597 |
|
| 598 |
const textContent = formatted?.content || formatted?.description || formatted?.text || formatted?.html;
|
| 599 |
+
let amount = 0;
|
| 600 |
do {
|
| 601 |
if (typeof textContent === 'string') {
|
| 602 |
amount = estimateToken(textContent);
|
backend/functions/src/cloud-functions/searcher.ts
CHANGED
|
@@ -90,7 +90,7 @@ export class SearcherHost extends RPCHost {
|
|
| 90 |
) {
|
| 91 |
const uid = await auth.solveUID();
|
| 92 |
let chargeAmount = 0;
|
| 93 |
-
const noSlashPath = ctx.req.url.slice(1);
|
| 94 |
if (!noSlashPath && !q) {
|
| 95 |
const latestUser = uid ? await auth.assertUser() : undefined;
|
| 96 |
if (!ctx.req.accepts('text/plain') && (ctx.req.accepts('text/json') || ctx.req.accepts('application/json'))) {
|
|
@@ -152,7 +152,7 @@ export class SearcherHost extends RPCHost {
|
|
| 152 |
delete crawlerOptions.html;
|
| 153 |
|
| 154 |
const crawlOpts = this.crawler.configure(crawlerOptions);
|
| 155 |
-
const searchQuery = braveSearchExplicitOperators.addTo(q ||
|
| 156 |
const r = await this.cachedWebSearch({
|
| 157 |
q: searchQuery,
|
| 158 |
count: Math.floor(count + 2)
|
|
|
|
| 90 |
) {
|
| 91 |
const uid = await auth.solveUID();
|
| 92 |
let chargeAmount = 0;
|
| 93 |
+
const noSlashPath = decodeURIComponent(ctx.req.url).slice(1);
|
| 94 |
if (!noSlashPath && !q) {
|
| 95 |
const latestUser = uid ? await auth.assertUser() : undefined;
|
| 96 |
if (!ctx.req.accepts('text/plain') && (ctx.req.accepts('text/json') || ctx.req.accepts('application/json'))) {
|
|
|
|
| 152 |
delete crawlerOptions.html;
|
| 153 |
|
| 154 |
const crawlOpts = this.crawler.configure(crawlerOptions);
|
| 155 |
+
const searchQuery = braveSearchExplicitOperators.addTo(q || noSlashPath);
|
| 156 |
const r = await this.cachedWebSearch({
|
| 157 |
q: searchQuery,
|
| 158 |
count: Math.floor(count + 2)
|
thinapps-shared
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
Subproject commit
|
|
|
|
| 1 |
+
Subproject commit da6e55d2d5ea310ebc443dab6cdca9f7a9d8e67d
|