SShortSingh.
Back to feed

How video titles become safe filenames: byte limits, path hazards and non-ASCII text

0
·4 views

A developer describing the download service ramrom.io explains how a video's title is turned into a filename. Titles are treated as untrusted input, so path separators, control characters and leading or trailing dots are removed to prevent unsafe or broken names. Because filesystems limit names to 255 bytes rather than characters, the author trims by byte count to 200, avoiding cuts that split multi-byte characters. Non-ASCII letters are kept so titles in languages like Urdu stay recognisable, while runs of emoji are collapsed. Empty results fall back to a generic name, and the filename is treated only as a label since different videos can share titles.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Reducing Redundant Client Data Fetches With Ownership, Deduplication, and Freshness Windows

A common source of performance problems is the client, where screens, focus changes, rerenders, and global events repeatedly trigger requests for unchanged data. These redundant calls add server load, mobile data and battery costs, rate-limit pressure, and visual instability. The article recommends assigning each resource a single refresh owner, deduplicating concurrent requests by resource key with a single-flight pattern, and defining a bounded freshness window. It also advises keeping the last successful value when a refresh fails and ensuring store updates cannot retrigger their own synchronization. Using translation loading as an example, it argues that reference data and configuration should only sync during explicit lifecycle events rather than every time a user revisits a screen.

0
ProgrammingDEV Community ·

Company site drops its server: static pages served from a CDN replace WordPress

A company website that once ran on a rented WordPress server now has no server, serving 166 pages in nine languages from Cloudflare's network. A typical WordPress setup runs PHP and a database for every visitor, which requires constant updates and exposes it to security risks and downtime during traffic spikes. Static sites are pre-built into HTML files and delivered from nearby data centres, offering faster loading, fewer attack surfaces, and lower costs for typical company sites. Forms and similar features can run as small edge functions, while content editing can use a headless CMS. The article notes WordPress remains the better choice for sites needing complex plugins or frequent non-technical publishing.

0
ProgrammingDEV Community ·

Why 'Works on My Machine' Happens and How Developers Can Fix It

Code that passes on a developer's laptop often fails in CI or production because the local machine holds hidden state the servers lack. Common culprits include unpinned dependency and runtime versions, gitignored environment variables, case-insensitive file paths on macOS, local timezones, and stale caches or globally installed tools. The article recommends committing lockfiles, pinning Node versions, keeping a committed .env.example with startup validation, matching file casing, storing dates in UTC, and testing under throttled networks. Its central advice is to make environments explicit and reproducible, for example through clean CI builds or Docker.

0
ProgrammingDEV Community ·

Reducing Query Count Makes APIs Faster Than Bigger Database Servers

A common cause of slow APIs is serialization silently triggering extra database queries for related data, known as the N+1 problem. Such issues often go unnoticed in development but become costly with production volumes, concurrent requests, and remote databases. The recommended fix is to map each response field to its data source, using select_related for single relationships and prefetch_related for collections. List endpoints should stay compact, with detailed data reserved for detail endpoints, and repeated counts moved into annotations or aggregate queries. Pagination should occur at the database level, with indexes supporting real filter and ordering patterns, and query counts should be measured and guarded by regression tests.