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

Fix Facebook videos if protocol isn't specified in data-href #1411

Merged
merged 1 commit into from
Sep 22, 2022

Conversation

kzar
Copy link
Collaborator

@kzar kzar commented Sep 20, 2022

Embedded Facebook videos are created by having a div element in the page that has (amongst other attributes) a data-href attribute that specifies the video's URL. The Facebook SDK then uses that to create the video iframe. Our "surrogate script" does the same.

It turns out that when the protocol prefix of that URL isn't specified (e.g. the URL starts '//'), then the SDK and our surrogate script need to take care to add the correct protocol to the URL (e.g. 'http:' or 'https:') based on the window location. Otherwise, the video fails to load.

Reviewer: @ladamski

Steps to test this PR:

  1. Navigate to https://forums.spacebattles.com/threads/ace-combat-7-discussion-thread.366416/page-160?post=61183897#post-61183897
  2. Click to load the Facebook video.
  3. Ensure it loads and can be played.

Automated tests:

  • Unit tests
  • Integration tests
Reviewer Checklist:
  • Ensure the PR solves the problem
  • Review every line of code
  • Ensure the PR does no harm by testing the changes thoroughly
  • Get help if you're uncomfortable with any of the above!
  • Determine if there are any quick wins that improve the implementation
PR Author Checklist:
  • Get advice or leverage existing code
  • Agree on technical approach with reviewer (if the changes are nuanced)
  • Ensure that there is a testing strategy (and documented non-automated tests)
  • Ensure there is a documented monitoring strategy (if necessary)
  • Consider systems implications

Embedded Facebook videos are created by having a div element in the
page that has (amongst other attributes) a data-href attribute that
specifies the video's URL. The Facebook SDK then uses that to create
the video iframe. Our "surrogate script" does the same.

It turns out that when the protocol prefix of that URL isn't specified
(e.g. the URL starts '//'), then the SDK and our surrogate script need
to take care to add the correct protocol to the URL (e.g. 'http:' or
'https:') based on the window location. Otherwise, the video fails to
load.
@kzar kzar requested a review from ladamski September 21, 2022 09:16
@kzar kzar marked this pull request as ready for review September 21, 2022 09:16
@jonathanKingston
Copy link
Collaborator

LGTM; I'm guessing @ladamski needs to port it into his work but yeah seems good.

Copy link
Contributor

@ladamski ladamski left a comment

Choose a reason for hiding this comment

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

Looks great, verified it works. Nice job!

@kzar kzar merged commit 85f2227 into duckduckgo:develop Sep 22, 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

Successfully merging this pull request may close these issues.

None yet

3 participants