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

Issue with relative paths in subfolders on w3s.link #1615

Open
ianconsolata opened this issue Jan 8, 2025 · 2 comments
Open

Issue with relative paths in subfolders on w3s.link #1615

ianconsolata opened this issue Jan 8, 2025 · 2 comments

Comments

@ianconsolata
Copy link

bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq is a folder containing 10 subfolders, each of which is a static archive of MIT OpenCourseware material. There is no index.html in the root, but there is in each subfolder.

When I load one of the subfolder sites in the w3s gateway, the CSS doesn't load, and the links don't work: https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.w3s.link/18-s191-introduction-to-computational-thinking-fall-2020

However, CSS and links work correctly on the dweb.link gateway: https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.dweb.link/18-s191-introduction-to-computational-thinking-fall-2020/

I think this is because they are relative links in the HTML, and the w3s gateway is interpreting that as relative to the root, rather than relative to the subfolder. For example, when I click on the syllabus link in the w3s gateway, I get directed to https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.w3s.link/pages/syllabus/index.html, which doesn't exist.

But in the dweb.link gateway the same link takes me to https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.dweb.link/18-s191-introduction-to-computational-thinking-fall-2020/pages/syllabus/index.html, which is the correct path.

That path does exist on the w3s gateway, so if it was linked to correctly the site would work as expected: https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.w3s.link/18-s191-introduction-to-computational-thinking-fall-2020/pages/syllabus/index.html, and weirdly enough the CSS loads fine there.

@travis
Copy link
Member

travis commented Jan 8, 2025

Interesting - it looks like at least one of the root causes here is a difference in redirect behavior between w3s.link and dweb.link - when I look at

https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.w3s.link

and

https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.dweb.link

I see that they both give me links with no trailing slash, like

https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.w3s.link/18-s191-introduction-to-computational-thinking-fall-2020

and

https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.dweb.link/18-s191-introduction-to-computational-thinking-fall-2020

but when I click on the links, dweb.link automatically adds a trailing slash, while w3s.link does not:

Screenshot 2025-01-08 at 1 36 14 PM Screenshot 2025-01-08 at 1 35 53 PM

@alanshaw do you remember any quirks like this around trailing slashes? do you think it would be a problem for us to adopt dweb.link's behavior and automatically redirect to urls with trailing slashes? I'm not entirely convinced it's even the right thing to do, but curious about whether we've considered this before.

@ianconsolata
Copy link
Author

I noticed they don't add a trailing slash on all of them. This link, for example, was to the index.html file directly and so didn't get it tacked on: https://bafybeiaq3hivs5tldezxg33j476ftbc5vxalhpdu3fuj5pyz27qyagcwhq.ipfs.dweb.link/18-s191-introduction-to-computational-thinking-fall-2020/pages/syllabus/index.html

I think it only makes sense to automatically add the trailing slash if the path being linked to is a directory.

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