Skip to content

Commit

Permalink
Merge pull request #145 from jordanopensource/patch/fix_build-warns
Browse files Browse the repository at this point in the history
Fix build warns
  • Loading branch information
thread-koder authored Nov 28, 2024
2 parents f413529 + 4456696 commit bc6e906
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 17 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ typings/

# nuxt.js build output
.nuxt
.output

# Nuxt generate
dist
Expand Down
7 changes: 4 additions & 3 deletions server/api/upload-comment.post.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { predictCommentsResults } from '../utils'
import { predictCommentsResults } from '../utils/nuha-api-request'
import { reject } from '../utils/promise-handlers'

export default defineEventHandler(async (event) => {
const data = await readBody<SingleComment>(event)
Expand Down Expand Up @@ -33,14 +34,14 @@ async function verifyData(input: SingleComment): Promise<void> {
}

const emailPattern = new RegExp(
/(?:[a-zA-Z\d!#$%&'*+/=?^_{|}~-]+(?:\.[a-zA-Z\d!#$%&'*+/=?^_{|}~-]+)*|"(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*")@(?:(?:[a-zA-Z\d](?:[a-zA-Z\d-]*[a-zA-Z\d])?\.)+[a-zA-Z\d](?:[a-zA-Z\d-]*[a-zA-Z\d])?|\[(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?|[a-zA-Z\d-]*[a-zA-Z\d]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)])/gm,
/^(?:[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,})$/gm
)
if (input.comment.match(emailPattern)) {
return reject('apiResponse.commentContainsEmail')
}

const urlPattern = new RegExp(
/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gm,
/[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/gm
)
if (input.comment.match(urlPattern)) {
return reject('apiResponse.commentContainsUrl')
Expand Down
4 changes: 2 additions & 2 deletions server/api/upload-file.post.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FileParser, getFileParser, getFileType } from '../utils'
import { FileParser, getFileParser, getFileType } from '../utils/file-parser'

export default defineEventHandler(async (event) => {
const files = await readMultipartFormData(event)
Expand All @@ -8,7 +8,7 @@ export default defineEventHandler(async (event) => {
}

const fileType = getFileType(
files[0].filename?.substring(files[0].filename?.lastIndexOf('.') + 1) ?? '',
files[0].filename?.substring(files[0].filename?.lastIndexOf('.') + 1) ?? ''
)
let err: unknown
const parser = await getFileParser(fileType).catch((_err) => {
Expand Down
1 change: 1 addition & 0 deletions server/utils/file-parser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { parse } from 'csv-parse/sync'
import { resolve, reject } from './promise-handlers'
import xlsx from 'node-xlsx'

export interface FileParser {
Expand Down
12 changes: 0 additions & 12 deletions server/utils/index.ts

This file was deleted.

0 comments on commit bc6e906

Please sign in to comment.