mirror of
https://github.com/zen-browser/rices.git
synced 2025-07-07 08:55:40 +02:00
fix user-agent update bug
fix remove extra base64 encoding fix update http tests
This commit is contained in:
parent
55fa0b747f
commit
612e27a55c
6 changed files with 12 additions and 21 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -13,7 +13,7 @@ yarn-error.log*
|
|||
lerna-debug.log*
|
||||
|
||||
#node
|
||||
*package.lock
|
||||
*package-lock.json
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
|
|
3
package-lock.json
generated
3
package-lock.json
generated
|
@ -3520,7 +3520,6 @@
|
|||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"base64-js": "^1.3.1",
|
||||
"ieee754": "^1.1.13"
|
||||
}
|
||||
},
|
||||
|
@ -9793,4 +9792,4 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -94,8 +94,6 @@ export class RicesService {
|
|||
}
|
||||
|
||||
const token = uuidv4();
|
||||
const encodedContent = Buffer.from(content).toString('base64');
|
||||
|
||||
const metadata = {
|
||||
id: uuidv4(),
|
||||
token,
|
||||
|
@ -115,7 +113,7 @@ export class RicesService {
|
|||
const uploadedFilePath = `rices/${slug}/data.zenrice`;
|
||||
await this.gitHubService.createOrUpdateFile(
|
||||
uploadedFilePath,
|
||||
encodedContent,
|
||||
content,
|
||||
`Add content to rice ${slug}`,
|
||||
);
|
||||
|
||||
|
@ -139,13 +137,10 @@ export class RicesService {
|
|||
throw new NotFoundException('Rice file not found in GitHub');
|
||||
}
|
||||
|
||||
// Decode Base64 content
|
||||
const contentPrev = Buffer.from(fileContent, 'base64').toString('utf-8');
|
||||
|
||||
// Remove unescaped double quotes at the beginning and end, if present
|
||||
const content = contentPrev.replace(/^"|"$/g, '');
|
||||
// const content = contentPrev.replace(/^"|"$/g, '');
|
||||
|
||||
return content;
|
||||
return fileContent;
|
||||
}
|
||||
|
||||
async update(
|
||||
|
@ -156,11 +151,11 @@ export class RicesService {
|
|||
) {
|
||||
try {
|
||||
// Extract fields from headers
|
||||
const userAgent = headers['User-Agent'];
|
||||
const userAgent = headers['user-agent'];
|
||||
|
||||
if (!userAgent) {
|
||||
throw new BadRequestException(
|
||||
'Missing required headers: X-Zen-Rice-Name, X-Zen-Rice-Author, and User-Agent are mandatory.',
|
||||
'Missing required headers: User-Agent is mandatory.',
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -202,11 +197,10 @@ export class RicesService {
|
|||
|
||||
await this.supabaseService.updateRice(slug, updatedMetadata);
|
||||
|
||||
const encodedContent = Buffer.from(content).toString('base64');
|
||||
const uploadedFilePath = `rices/${slug}/data.zenrice`;
|
||||
await this.gitHubService.createOrUpdateFile(
|
||||
uploadedFilePath,
|
||||
encodedContent,
|
||||
content,
|
||||
`Update content in rice ${slug}`,
|
||||
);
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
POST {{baseUrl}}/rices
|
||||
Content-Type: application/json
|
||||
X-Zen-Rice-Name: cool-zenrice-aurora2
|
||||
X-Zen-Rice-Name: cool-zenrice-test-base64211
|
||||
X-Zen-Rice-Author: jhon@doe.com
|
||||
User-Agent: ZenBrowser/1.2b.0 (EndeavourOS x86_64)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
@baseUrl = http://localhost:3000
|
||||
@previous_slug = cool-zenrice-aurora2-4fe6417d-f901-43d2-92fc-720c6ed3e449
|
||||
@previous_slug = cool-zenrice-test-base64211-5f874c8c-71f7-4b45-830a-aa86c9328455
|
||||
|
||||
|
||||
GET {{baseUrl}}/rices/{{previous_slug}}
|
|
@ -1,12 +1,10 @@
|
|||
@baseUrl = http://localhost:3000
|
||||
@previous_slug = cool-zenrice-aurora2-4fe6417d-f901-43d2-92fc-720c6ed3e449
|
||||
@previous_token = e3ec0c0f-f455-4a4e-a06d-69d2e3bbf46c
|
||||
@previous_slug = cool-zenrice-test-base64211-5f874c8c-71f7-4b45-830a-aa86c9328455
|
||||
@previous_token = 84780af0-191e-4f77-8c23-25165c89d27e
|
||||
|
||||
PUT {{baseUrl}}/rices/{{previous_slug}}
|
||||
Content-Type: application/json
|
||||
x-zen-rices-token: {{previous_token}}
|
||||
X-Zen-Rice-Name: cool-zenrice-aurora2
|
||||
X-Zen-Rice-Author: jhon@doe.com
|
||||
User-Agent: ZenBrowser/1.2b.0 (EndeavourOS x86_64)
|
||||
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue