Code works in Chrome but not in Firefox?

For this file-name Yemin 245. Bölüm.mp4 having UTF characters the following code in my web-extension works fine in Google Chrome and the file gets downloaded (EDIT: No matter what filename I use this is resulting in error, it seems some update in Firefox broke this). But, firefox fails with error Unchecked lastError value: Error: filename must not contain illegal characters:

In background.js

chrome.runtime.onMessage.addListener(function (message) {
	var url = message.url;
	var fname = message.filename;
	fname = fname.replace(/[\\\/:"*?<>|\r\n]+/g, "_");

	chrome.downloads.download({
		url: url,
		filename: fname,
		conflictAction: 'uniquify',
		saveAs: true
	});
});

What am I missing here?

Just tried this and it seems to work fine:

browser.downloads.download({
    url: 'https://discourse.mozilla.org/t/code-works-in-chrome-but-not-in-firefox/59987',
    filename: 'Yemin 245. Bölüm.mp4'.replace(/[\\\/:"*?<>|\r\n]+/g, "_"),
    conflictAction: 'uniquify',
    saveAs: true
})

You might have something missing in your example which causes the problem.

Pls.check this - https://stackoverflow.com/questions/61801645/web-extension-code-to-download-file-works-in-chrome-but-fails-in-firefox-with-i , any explanations?

@Lusito Pls. check your code with double spaces. Does it work?

So your samples, when pasted don’t have the double whitespace mentioned on stackoverflow. I can reproduce with the text one<space><space>two.txt. Not sure what this is about, but I think you should create a ticket on bugzilla. This doesn’t seem right. You can work arround this by changing your script to replace consecutive whitespace characters with just a single one:

fname.replace(/[\\\/:"*?<>|\r\n]+/g, "_").replace(/\s\s+/g, " ")