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

What is a fileReference name? #278

Closed
Fil opened this issue Nov 29, 2023 · 5 comments
Closed

What is a fileReference name? #278

Fil opened this issue Nov 29, 2023 · 5 comments
Assignees
Labels
question Further information is requested
Milestone

Comments

@Fil
Copy link
Contributor

Fil commented Nov 29, 2023

As I was reviewing tests in #277, I realized that the fileReference name is a path (like ./test.png), not a basename (test.png). In particular, if you have two fileReferences in the same page, say one to test.png and the other to ./test.png, the name field is arbitrarily the one or the other.

We can normalize that name by removing a starting ./, but it still bugs me that the name is a path (especially since we also have a path field). Note that in build.ts we use this name as a path, when the file is not in the page directory.

@Fil Fil added the question Further information is requested label Nov 29, 2023
@cinxmo
Copy link
Contributor

cinxmo commented Nov 29, 2023

I understand it as the exact string the user passes to the src attribute or the FileAttachment argument. We could clarify here:
https://github.com/observablehq/cli/blob/052835b46f2748682d036c3c1cec5302e336e142/docs/javascript/files.md?plain=1#L103

@mbostock
Copy link
Member

The name has to match what is passed to FileAttachment exactly, so that we can look it up in the map. That is, unless you want to rewrite the argument we pass to FileAttachment, or do some further normalization in resolveFile.

@mbostock
Copy link
Member

I agree it would be better if the exposed file.name were just the name and not a path… That’s not something we ever ran into before with notebooks since we didn’t allow paths. 😅

@cinxmo
Copy link
Contributor

cinxmo commented Nov 29, 2023

I think there's a bug in my code since I de-dup based on file.path but we look up based on file.name...

@cinxmo cinxmo added this to the Early access milestone Dec 5, 2023
@cinxmo
Copy link
Contributor

cinxmo commented Dec 5, 2023

Actually the current implementation is fine since we're not referring to the files via FileAttachment(...). Closing this ticket

@cinxmo cinxmo closed this as completed Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants