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

Viewer origins #18

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Viewer origins #18

wants to merge 5 commits into from

Conversation

siegy22
Copy link
Collaborator

@siegy22 siegy22 commented Jul 29, 2016

closes #12, closes #16

@andyweiss1982 and @senny have a 👀

function validateFileURL(file) {
try {
var viewerOrigin = new URL(window.location.href).origin || 'null';
var viewerOrigin = window.location.origin;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why was this change necessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that this does the same thing (it's more readable). But according to https://developer.mozilla.org/en-US/docs/Web/API/Window/location you can't use window.location.origin is only available since IE 11, I think this is an IE workaround.
See this: http://tosbourn.com/a-fix-for-window-location-origin-in-internet-explorer/

I'll undo that change.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Elektron1c97 also we don't want to change that code really. It's property of the PDF.js project. Every update we make needs to reapply these changes.

@senny
Copy link
Owner

senny commented Jul 29, 2016

@MattFenelon can you get your use-case to work with this addition?

function validateFileURL(file) {
try {
// IE workaround because window.location.origin
// is not available in < IE 11
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for a comment. We don't want to own this code. We just use what we get from PDF.js

@senny
Copy link
Owner

senny commented Jul 29, 2016

@siegy22 A test-case needs to make sure the env variable has an effect. Otherwise we are going to loose this on an update.

@@ -1,6 +1,8 @@
# Configure Rails Environment
ENV["RAILS_ENV"] = "test"

ENV["PDFJS_VIEWER_ORIGINS"] = "http://example.com,http://random.example.com"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be set in the respective test-case and be reset after it (in an ensure)

@senny
Copy link
Owner

senny commented Jul 29, 2016

Let's wait for feedback if this addresses the need voiced by others.

@siegy22
Copy link
Collaborator Author

siegy22 commented Jul 29, 2016

That's okay for me 👌

@MattFenelon
Copy link

This looks great, thanks for looking at it. I won't be able to test it until Monday now.

As you own _viewer.html, rather than change viewer.js, could you modify HOSTED_VIEWER_ORIGINS in a js file loaded after viewer.js?

@siegy22
Copy link
Collaborator Author

siegy22 commented Jul 29, 2016

Hey @MattFenelon I opened another pr ( #19 )

I explored a little "bug" in the code. Gonna fix this tommorow!

@fatuhoku
Copy link

What's the latest on this?

@monochrome-particles
Copy link

Any updates on this? When are you planning to merge this? I would really like to have configurable origins :'(

@raykin
Copy link

raykin commented Jul 6, 2017

it's useful when viewing PDF saved in S3 or cloud service

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

Successfully merging this pull request may close these issues.

Use externally hosted PDFs (Amazon S3, etc)
6 participants