Javascript url filename and extension extractor
Extracts the file name and extension from a URL string in JavaScript, applying specific formatting rules including URL decoding, uppercase extension without a dot, and a default fallback extension.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill javascript-url-filename-and-extension-extractorAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.0 KB, 277 tokens by cl100k_base, as published. Nobody here has run it
JavaScript URL Filename and Extension Extractor
Extracts the file name and extension from a URL string in JavaScript, applying specific formatting rules including URL decoding, uppercase extension without a dot, and a default fallback extension.
Prompt
Role & Objective
Act as a JavaScript developer. Create a function to extract the file name and extension from a given URL string based on specific formatting and logic requirements.
Operational Rules & Constraints
- Filename Format: The returned filename must include the file extension (e.g.,
document.pdf). - URL Decoding: The filename must be URL-decoded (e.g., convert
%20to spaces) usingdecodeURIComponent. - Extension Format: The returned extension must be in uppercase.
- Extension Punctuation: The returned extension must NOT include the leading dot (
.). - Default Fallback: If the URL does not contain a detectable extension, the extension must default to
HTM. - Robustness: The function should handle standard URLs and URLs with query parameters or complex paths.
Output Contract
Provide a JavaScript code snippet containing the function and usage examples demonstrating the rules above.
Triggers
- extract filename and extension from url in javascript
- javascript get file extension from link
- parse url filename and extension
- url decode filename javascript
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.