Skip to content

style: Format all files with Prettier#16

Merged
gautammanak1 merged 1 commit intomainfrom
fix/prettier-formatting
Nov 19, 2025
Merged

style: Format all files with Prettier#16
gautammanak1 merged 1 commit intomainfrom
fix/prettier-formatting

Conversation

@gautammanak1
Copy link
Owner

  • Run prettier --write on all files
  • Fix formatting issues in 42 files
  • Ensure consistent code style across project

Description

Type of Change

  • 🐛 Bug fix (non-breaking change which fixes an issue)
  • ✨ New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📝 Documentation update
  • 🎨 Style/formatting changes (no code change)
  • ♻️ Code refactoring (no functional changes)
  • ⚡ Performance improvements
  • ✅ Tests (adding or updating tests)

Related Issues

Closes #

Changes Made

Screenshots (if applicable)

Before After

Testing

  • I have tested this locally
  • I have added/updated tests
  • All existing tests pass
  • I have tested in multiple browsers
  • I have tested in both light and dark modes
  • I have tested responsive design on mobile devices

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have updated the documentation accordingly
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Additional Notes

- Run prettier --write on all files
- Fix formatting issues in 42 files
- Ensure consistent code style across project
@vercel
Copy link

vercel bot commented Nov 18, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
npm-package-download-stat Ready Ready Preview Comment Nov 18, 2025 11:39pm

<p className="text-sm text-muted-foreground mt-2">
<strong>Alternative:</strong> Check{" "}
<a
href={`https://pypistats.org/packages/${packageInfo?.info?.name || packageName}`}

Check warning

Code scanning / CodeQL

DOM text reinterpreted as HTML Medium

DOM text
is reinterpreted as HTML without escaping meta-characters.

Copilot Autofix

AI 4 months ago

To fix the problem, sanitize and validate any user-supplied data before interpolating it into the anchor tag’s href attribute. Since the external service only expects package names that match a well-defined format (typically, a valid package name for npm or PyPI), we should ensure packageName and packageInfo?.info?.name are valid package names before constructing URLs with them. A simple way is to define a function that strips or restricts disallowed characters (i.e., only allow valid package name characters: alphanumerics, dashes, underscores, periods), and use it to sanitize the names before constructing the href URL. As the code only shows the anchor interpolation region, the best fix is to wrap the interpolated value with a sanitizer. Implement the function in the same file (since only app/page.tsx is shown), and use it at the link construction site.


Suggested changeset 1
app/page.tsx

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/app/page.tsx b/app/page.tsx
--- a/app/page.tsx
+++ b/app/page.tsx
@@ -27,6 +27,12 @@
 
 type PackageManager = "npm" | "pypi";
 
+// Sanitize package names by stripping unsafe characters
+function sanitizePackageName(pkgName: string): string {
+  // Accept alphanumeric, underscore, dash, dot; remove everything else
+  return (pkgName || "").replace(/[^a-zA-Z0-9._-]/g, "");
+}
+
 export default function Home() {
   const [packageManager, setPackageManager] = useState<PackageManager>("npm");
   const [packageName, setPackageName] = useState("");
@@ -699,7 +705,7 @@
                             <p className="text-sm text-muted-foreground mt-2">
                               <strong>Alternative:</strong> Check{" "}
                               <a
-                                href={`https://pypistats.org/packages/${packageInfo?.info?.name || packageName}`}
+                                href={`https://pypistats.org/packages/${sanitizePackageName(packageInfo?.info?.name || packageName)}`}
                                 target="_blank"
                                 rel="noopener noreferrer"
                                 className="text-primary hover:underline"
EOF
@@ -27,6 +27,12 @@

type PackageManager = "npm" | "pypi";

// Sanitize package names by stripping unsafe characters
function sanitizePackageName(pkgName: string): string {
// Accept alphanumeric, underscore, dash, dot; remove everything else
return (pkgName || "").replace(/[^a-zA-Z0-9._-]/g, "");
}

export default function Home() {
const [packageManager, setPackageManager] = useState<PackageManager>("npm");
const [packageName, setPackageName] = useState("");
@@ -699,7 +705,7 @@
<p className="text-sm text-muted-foreground mt-2">
<strong>Alternative:</strong> Check{" "}
<a
href={`https://pypistats.org/packages/${packageInfo?.info?.name || packageName}`}
href={`https://pypistats.org/packages/${sanitizePackageName(packageInfo?.info?.name || packageName)}`}
target="_blank"
rel="noopener noreferrer"
className="text-primary hover:underline"
Copilot is powered by AI and may make mistakes. Always verify output.
@gautammanak1 gautammanak1 merged commit a20bdfe into main Nov 19, 2025
9 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant