Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions static/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,9 +350,10 @@ if (isIndexPage) {
}

function syncSkillsHiddenInput() {
// Keep the hidden <input> in sync for form serialisation
// The API expects a comma-separated string, so join the array that way
skillsHidden.value = selectedSkills.join(", ");
// Keep the hidden <input> in sync for form serialisation.
// JSON.stringify preserves skill names that contain commas (e.g. "HTML, CSS")
// so the backend can reconstruct the exact array without mis-splitting.
skillsHidden.value = JSON.stringify(selectedSkills);
}

updateQuickPickState();
Expand Down
34 changes: 24 additions & 10 deletions utils/recommender.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,32 @@

def parse_skills(skills_string):
"""
Convert a raw comma-separated skills string into
a normalized lowercase list.
Convert a skills string into a normalized lowercase list.
Example:
"JS, HTML5, CSS3" -> ["javascript", "html", "css"]
"""
Accepts two formats:
1. JSON array (preferred): '["HTML, CSS", "JavaScript"]'
Handles skill names that contain commas without mis-splitting.
2. Comma-separated string (legacy fallback): "HTML, CSS, JavaScript"
raw_skills = [
s.strip().lower()
for s in skills_string.split(",")
if s.strip()
]
Example:
'["JS", "HTML5", "CSS3"]' -> ["javascript", "html", "css"]
"""
import json

try:
# Preferred path: frontend sends a JSON-serialized array
parsed = json.loads(skills_string)
if isinstance(parsed, list):
raw_skills = [s.strip().lower() for s in parsed if isinstance(s, str) and s.strip()]
else:
raise ValueError("Parsed JSON is not a list")
except (json.JSONDecodeError, ValueError, TypeError):
# Fallback: handle plain comma-separated strings
raw_skills = [
s.strip().lower()
for s in skills_string.split(",")
if s.strip()
]

normalized_skills = [
SKILL_ALIASES.get(skill, skill)
Expand Down
Loading