-
Notifications
You must be signed in to change notification settings - Fork 524
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(livesamples): use correct legacy url #9158
Merged
+39
−30
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,25 +4,27 @@ | |
// | ||
// Parameters: | ||
// | ||
// $0 The ID of the sample's section or containing block. | ||
// $1 The URL from which to pull the sample; if not provided, | ||
// $0 - The ID of the sample's section or containing block. | ||
// $1 - (Deprecated) The URL from which to pull the sample; if not provided, | ||
// the current page is assumed. | ||
|
||
var pagePath = env.url; | ||
let pagePath = env.url; | ||
let baseUrl = env.live_samples.base_url; | ||
let samplePath = `${pagePath}/runner.html`.replace(/\/\/+/g, "/"); | ||
|
||
if ($1 && $1.length > 0) { | ||
mdn.deprecatedParams("The second parameter of 'LiveSampleURL' is deprecated"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, the message would have an actionable suggestion on how to proceed. I guess in this case the original example has to be copied into the page, right? |
||
pagePath = $1; | ||
baseUrl = env.live_samples.legacy_url; | ||
samplePath = `${pagePath}/_sample_.${web.slugify(web.safeDecodeURIComponent($0))}.html`.replace(/\/\/+/g, "/"); | ||
} | ||
|
||
const searchParams = new URLSearchParams([["id", $0], ["url", $1]].filter(([_,v]) => Boolean(v))); | ||
wiki.ensureExistence(pagePath); | ||
const samplePath = $1 ? | ||
`${pagePath}/_sample_.${web.slugify(web.safeDecodeURIComponent($0))}.html`.replace(/\/\/+/g, "/") | ||
: `${pagePath}/runner.html`.replace(/\/\/+/g, "/"); | ||
const searchParams = new URLSearchParams([["id", $0], ["url", $1]].filter(([_,v]) => Boolean(v))); | ||
|
||
let url; | ||
if (env.live_samples.base_url.includes('://')) { | ||
url = new URL(env.live_samples.base_url); | ||
if (baseUrl.includes('://')) { | ||
url = new URL(baseUrl); | ||
url.pathname = samplePath; | ||
url.search = searchParams.toString(); | ||
} else { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you're cleaning up the macro anyways, can you assign $0 and $1 to variables
id
andurl
or similar to avoid referencing $0 and $1 below?