analogjs / analog

The fullstack meta-framework for Angular. Powered by Vite and Nitro
https://analogjs.org
MIT License
2.59k stars 249 forks source link

Doesn't work with Arabic Slug #1400

Open AbdallahR99 opened 1 month ago

AbdallahR99 commented 1 month ago

Please provide the environment you discovered this bug in.

windows 11

{
  "name": "analog-blog-test",
  "version": "0.0.0",
  "type": "module",
  "engines": {
    "node": ">=18.19.1"
  },
  "scripts": {
    "ng": "ng",
    "dev": "ng serve",
    "start": "pnpm run dev",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@analogjs/content": "^1.8.2",
    "@analogjs/router": "^1.8.2",
    "@angular/animations": "^18.2.7",
    "@angular/build": "^18.2.7",
    "@angular/cdk": "18.2.7",
    "@angular/common": "^18.2.7",
    "@angular/compiler": "^18.2.7",
    "@angular/core": "^18.2.7",
    "@angular/forms": "^18.2.7",
    "@angular/material": "18.2.7",
    "@angular/platform-browser": "^18.2.7",
    "@angular/platform-browser-dynamic": "^18.2.7",
    "@angular/platform-server": "^18.2.7",
    "@angular/router": "^18.2.7",
    "@auth0/angular-jwt": "^5.2.0",
    "@ngx-translate/core": "^15.0.0",
    "@ngx-translate/http-loader": "^8.0.0",
    "flowbite": "^2.5.1",
    "front-matter": "^4.0.2",
    "guid-ts": "^1.1.2",
    "marked": "^5.1.2",
    "marked-gfm-heading-id": "^3.2.0",
    "marked-highlight": "^2.1.4",
    "marked-mangle": "^1.1.9",
    "prismjs": "^1.29.0",
    "rollup-plugin-typescript-paths": "^1.5.0",
    "rxjs": "~7.8.1",
    "tslib": "^2.7.0",
    "uuid": "^10.0.0",
    "zone.js": "~0.14.10"
  },
  "devDependencies": {
    "@analogjs/platform": "^1.8.2",
    "@analogjs/vite-plugin-angular": "^1.8.2",
    "@analogjs/vitest-angular": "^1.8.2",
    "@angular/cli": "^18.2.7",
    "@angular/compiler-cli": "^18.2.7",
    "autoprefixer": "^10.4.20",
    "daisyui": "^4.12.10",
    "jsdom": "^22.1.0",
    "postcss": "^8.4.47",
    "schematics-scss-migrate": "^2.3.17",
    "tailwindcss": "^3.4.12",
    "typescript": "~5.4.5",
    "vite": "^5.4.7",
    "vite-tsconfig-paths": "^4.3.2",
    "vitest": "^1.6.0"
  },
  "packageManager": "pnpm@9.11.0+sha512.0a203ffaed5a3f63242cd064c8fb5892366c103e328079318f78062f24ea8c9d50bc6a47aa3567cabefd824d170e78fa2745ed1f16b132e16436146b7688f19b"
}

Which area/package is the issue in?

content

Description

Found that Arabic slugs doesn't work, only the English one image

image

image

Please provide the exception or error you saw

No response

Other information

No response

I would be willing to submit a PR to fix this issue

AbdallahR99 commented 1 month ago

image

it is because the slug is encoded

anyway to make it to read it in a decoded way?

or encoding the slug route param

Rockerturner commented 1 month ago

AFAIK slugs are always going to be encoded. The reason why 'swimming-pool-services' work is because the encoded and decoded versions are the same. If it were 'swimming pool services,' the encoded version would look like 'swimming%20pool%20services,' and it would have the same issues as yours. I can't see all the codes, but I assume you use the slug to compare or make a service call. However, the service call or comparison is not working as intended because it's encoded. The easiest fix would be to decode before you do anything with the slug. DecodeURI(slug) is what you are looking for.