Skip to content

Fix variable redeclaration in url.origin code example #40529

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

Merged
merged 5 commits into from
Jul 28, 2025

Conversation

jiangying000
Copy link
Contributor

const url = new URL("blob:https://mozilla.org:443/");
console.log(url.origin); // 'https://mozilla.org'

const url = new URL("http://localhost:80/");
console.log(url.origin); // 'http://localhost'

const url = new URL("https://mozilla.org:8080/");
console.log(url.origin); // 'https://mozilla.org:8080'

Error:
Uncaught SyntaxError: Identifier 'url' has already been declared

@jiangying000 jiangying000 requested a review from a team as a code owner July 25, 2025 11:42
@jiangying000 jiangying000 requested review from sideshowbarker and removed request for a team July 25, 2025 11:42
@github-actions github-actions bot added Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed labels Jul 25, 2025
Copy link
Contributor

github-actions bot commented Jul 25, 2025

Preview URLs

(comment last updated: 2025-07-28 14:35:56)

@dipikabh
Copy link
Contributor

dipikabh commented Jul 25, 2025

Thanks for the PR @jiangying000.

I see that the current presentation of the code might be confusing. The likely intention of the original code would have been to show these as standalone examples and to not run all the lines together. It might be better instead to separate these into three JS code blocks.

Would you be able to send an update? Thanks!

@dipikabh dipikabh changed the title Update index.md Fix variable redeclaration in url.origin code example Jul 25, 2025
@sideshowbarker sideshowbarker removed their request for review July 26, 2025 00:42
@jiangying000
Copy link
Contributor Author

Thanks for the PR @jiangying000

I see that the current presentation of the code might be confusing. The likely intention of the original code would have been to show these as standalone examples and to not run all the lines together. It might be better instead to separate these into three JS code blocks. 

Would be able to send an update? Thanks!

Thanks for the feedback. Done.

jiangying000 and others added 2 commits July 26, 2025 19:44
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@github-actions github-actions bot added size/xs [PR only] 0-5 LoC changed and removed size/s [PR only] 6-50 LoC changed labels Jul 26, 2025
@github-actions github-actions bot added size/s [PR only] 6-50 LoC changed and removed size/xs [PR only] 0-5 LoC changed labels Jul 28, 2025
Copy link
Contributor

@dipikabh dipikabh left a comment

Choose a reason for hiding this comment

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

Thanks a lot, @jiangying000!

@dipikabh dipikabh merged commit ad6c8d2 into mdn:main Jul 28, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:WebAPI Web API docs size/s [PR only] 6-50 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants