gildas-lormeau/SingleFile · error · Error
URL is empty
Error message
URL is empty
What it means
addRule validates its url argument and throws 'URL is empty' when the value is falsy (undefined, null, or empty string). A rule maps a URL pattern to a profile, so an empty URL would create a meaningless/unmatchable rule. The throw happens before getRules() so storage is never touched.
Source
Thrown at src/core/bg/config.js:674
async function getProfileKeyNames() {
return Object.keys(await configStorage.get()).filter(key => key.startsWith(PROFILE_NAME_PREFIX));
}
async function getProfile(profileName) {
const profileKey = PROFILE_NAME_PREFIX + profileName;
const data = await configStorage.get([profileKey]);
return data[profileKey];
}
async function setProfile(profileName, profileData) {
const profileKey = PROFILE_NAME_PREFIX + profileName;
await configStorage.set({ [profileKey]: profileData });
}
async function addRule(url, profile, autoSaveProfile) {
if (!url) {
throw new Error("URL is empty");
}
const rules = await getRules();
if (rules.find(rule => rule.url == url)) {
throw new Error("URL already exists");
}
rules.push({
url,
profile,
autoSaveProfile
});
await configStorage.set({ rules });
}
async function deleteRule(url) {
if (!url) {
throw new Error("URL is empty");
}
const rules = await getRules();View on GitHub (pinned to 517fb7c5cf)
Solutions
- Validate the URL input in the UI before calling addRule and show a required-field error.
- Trim the input: addRule(url.trim(), ...) and check length > 0 before invoking.
- Ensure message senders include the url property (check key spelling in the onMessage payload).
Example fix
// before
await addRule(urlInput.value, profile);
// after
const url = urlInput.value.trim();
if (!url) throw new Error('URL is required');
await addRule(url, profile); Defensive patterns
Strategy: validation
Validate before calling
const url = (urlInput.value || '').trim();
if (!url) throw new Error('URL is required');
await addRule(url, profile, autoSaveProfile); Type guard
const isNonEmptyString = (v) => typeof v === 'string' && v.trim().length > 0;
Try / catch
try { await addRule(url, profile); } catch (e) { if (e.message === 'URL is empty') showFieldError('url', 'Required'); else throw e; } Prevention
- Mark the URL input required in the form
- Trim user input before API calls
- Verify message payloads include the url key
When it happens
Trigger: Calling addRule('', profile, autoSaveProfile) or addRule(undefined, ...) — typically from an options-page form where the URL input was left blank, or from a message handler that dropped the url field.
Common situations: Submitting an 'add rule' form without filling the URL field; a messaging bug where the payload key is misspelled so url arrives undefined.
Related errors
- URL already exists
- URL not found
- New URL already exists
- Default settings cannot be deleted
- Cannot identify the extension requesting SingleFile capture
AI-assisted analysis of gildas-lormeau/SingleFile@517fb7c5cf (2026-09-01).
Data as JSON: /api/errors/8dfc831981b24ae9.
Report an issue: GitHub.