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

There is no way to get the URL when protocol is file:// #196

Closed
zamicol opened this issue Aug 23, 2022 · 2 comments
Closed

There is no way to get the URL when protocol is file:// #196

zamicol opened this issue Aug 23, 2022 · 2 comments

Comments

@zamicol
Copy link

zamicol commented Aug 23, 2022

There is no way to get the URL if the protocol is file://

performance.getEntriesByType("navigation")[0].name does not work when the protocol is file://. performance is the suggested workaround for document.url and others, but this isn't tenable either. I'm not sure why performance doesn't work here, I'd love to know the reason.

As far as the TextFragmentAPI is concerned, I'm on Chrome version 104.0.5112.79 and the TextFragmentAPI doesn't seem to have anything usable here as implemented. The API doc has some useful interfaces, but they don't exist in the object.

Using this URL: https://en.wikipedia.org/wiki/Question#:~:text=linguistically%2C%20a%20question%20may%20be%20defined%20on%20three%20levels.

I get a fragmentDirective that's missing anything useful, such as items:
image

@bokand
Copy link
Collaborator

bokand commented Sep 9, 2022

The API is something I've been thinking about but haven't gotten past the idea stage - it's implemented in Chrome but behind a flag so it isn't shipped by default. You can try it out by starting chrome with the --enable-blink-features=TextFragmentAPI flag. (alternatively, I believe enabling chrome://flags/#enable-experimental-web-platform-features should also do the trick)

performance is the suggested workaround for document.url and others

I wouldn't say it's suggested - it works today (where the performance API does) but I think it's a bit of a hack that we'd like to eventually remove. See https://crbug.com/1096983

@zamicol
Copy link
Author

zamicol commented Sep 19, 2022

Thank you @bokand. 👍

Currently, text fragment will only appear in fragment directive when chrome://flags/#enable-experimental-web-platform-features is enabled. I mistakenly thought FragmentDirective's existence guaranteed the needed flags were already enabled.

Also for future readers: I don't know why performance does not contain url /name when the protocol is file:// and I can't find anything googling. If someone knows why, send me a message and I'll update this comment. For now, I'll assume it has something to do with security restrictions on file://.

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