question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Site config url + baseUrl are not normalized and sensitive to leading/trailing slash

See original GitHub issue

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I’m using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Meta data “og:url” - url has double slashes in the prerendered HTML

<meta data-rh="true" property="og:url" content="https://example.com//docs/courses/how-are-the-course-accessed-with-the-lifetime-membership/">

It happens when slash is added at the end of the URL in docusaurus.config.js, in my case
url: 'https://example.com/'

Reproducible demo

No response

Steps to reproduce

  1. Set in config url to: https://example.com/
  2. Build
  3. Search HTML code for og:url

Expected behavior

One slash in the URL

Actual behavior

Double slashes in the URL

Your environment

  • Public source code:
  • Public site URL: docs.divi.space
  • Docusaurus version used: 2.0.1
  • Environment name and version (e.g. Chrome 89, Node.js 16.4): node v16.17.0
  • Operating system and version (e.g. Ubuntu 20.04.2 LTS): macOS Monterey 12.2

Self-service

  • I’d be willing to fix this bug myself.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
Josh-Cenacommented, Aug 24, 2022

Correct, I’m also a bit confused why our validation fails baseUrl without starting/ending / when it could normalize that quite easily.

0reactions
slorbercommented, Aug 24, 2022

Yes we don’t really make it failsafe on url/baseUrl config.

Even if user is using baseurl without leading/trailing slash afaik it cause troubles.

I’d be happy to normalize those:

  • URL should not end with /
  • baseUrl should start/end with /

I don’t think our config should reject/warn, but maybe just fix the user config automatically?

Read more comments on GitHub >

github_iconTop Results From Across the Web

baseURL trailing slash should be consistent between site ...
Hello - it's been a while. If I set a baseURL in my config.toml, such as http://www.mysite.com, when I use {{ .Site.BaseURL }},...
Read more >
Should I configure my URLs with a leading and/or trailing slash?
No leading slashes, but always use trailing ones ( http://my.app/ , path/to/resource/ ). Is there a best strategy? Would the strategies be ...
Read more >
javascript - Return string without trailing slash - Stack Overflow
Try this: function someFunction(site) { return site.replace(/\/$/, ""); }.
Read more >
Changelog - Rclone
Config parameters can now be passed as part of the remote name as a connection string. For example, to do the equivalent of...
Read more >
REDCap Change Log - Eastern Virginia Medical School
Major bug fix: When attempting to upgrade to REDCap 12.5.13 (Standard), the REDCap upgrade page would mistakenly redirect the user back to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found