Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to enforce case sensitivity #141

Closed
benmccann opened this issue Jul 20, 2022 · 1 comment
Closed

Option to enforce case sensitivity #141

benmccann opened this issue Jul 20, 2022 · 1 comment

Comments

@benmccann
Copy link
Contributor

benmccann commented Jul 20, 2022

This request is the opposite of #92 and much easier to implement than that one

I'd like an option to only serve a file if the case matches what's on the filesystem. That's how it works on Linux, but Mac and Windows have a different behavior. It'd be nice to have the ability to enforce a consistent behavior.

SvelteKit has this implementation:

/**
 * Determine if a file is being requested with the correct case,
 * to ensure consistent behaviour between dev and prod and across
 * operating systems. Note that we can't use realpath here,
 * because we don't want to follow symlinks
 * @param {string} file
 * @param {string} assets
 * @returns {boolean}
 */
function has_correct_case(file, assets) {
	if (file === assets) return true;

	const parent = path.dirname(file);

	if (fs.readdirSync(parent).includes(path.basename(file))) {
		return has_correct_case(parent, assets);
	}

	return false;
}

However, I'd like it to live in sirv so that we can use it in Vite as well

@lukeed
Copy link
Owner

lukeed commented Oct 1, 2022

From discord:

Case sensitivity is platform specific. Fucking with it one way or another is a mistake

@lukeed lukeed closed this as not planned Won't fix, can't repro, duplicate, stale Oct 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants