Skip to content

prevent double-slash in asset paths (//assets/ --> /assets/) #925

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

Open
wants to merge 1 commit into
base: 2.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/content/reference/en/p5.Font/textToContours.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ example:

async function setup() {
createCanvas(100, 100);
font = await loadFont('//assets/inconsolata.otf');
font = await loadFont('/assets/inconsolata.otf');
}

function draw() {
Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/en/p5.MediaElement/src.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ example:
// Create a p5.MediaElement using createAudio().
beat = createAudio('/assets/beat.mp3');

describe('The text "https://p5js.org/reference//assets/beat.mp3" written in black on a gray background.');
describe('The text "https://p5js.org/reference/assets/beat.mp3" written in black on a gray background.');
}

function draw() {
Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/en/p5.SoundFile/frames.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ example:
let player;

function preload() {
player = loadSound('//assets/lucky_dragons_-_power_melody.mp3');
player = loadSound('/assets/lucky_dragons_-_power_melody.mp3');
}

function setup() {
Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/en/p5.SoundFile/onended.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ example:
let player;

function preload() {
player = loadSound('//assets/lucky_dragons_-_power_melody.mp3');
player = loadSound('/assets/lucky_dragons_-_power_melody.mp3');
}

function setup() {
Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/en/p5.SoundFile/pause.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ example:
let player;

function preload() {
player = loadSound('//assets/Damscray_DancingTiger.mp3');
player = loadSound('/assets/Damscray_DancingTiger.mp3');
}

function setup() {
Expand Down
4 changes: 2 additions & 2 deletions src/content/reference/en/p5.SoundFile/setPath.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ example:
let soundSource, cnv, btn;

function preload() {
soundSource = loadSound('//assets/Damscray_-_Dancing_Tiger_01.mp3');
soundSource = loadSound('/assets/Damscray_-_Dancing_Tiger_01.mp3');
}

function setup() {
Expand All @@ -40,7 +40,7 @@ example:
function setNewPath() {
background(220);
text('a new sound was loaded', 0, 20, 100);
soundSource.setPath('//assets/Damscray_-_Dancing_Tiger_02.mp3', playSound);
soundSource.setPath('/assets/Damscray_-_Dancing_Tiger_02.mp3', playSound);
}
</code>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/en/p5.Table/addColumn.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ example:

async function setup() {
createCanvas(300, 300);
table = await loadTable('//assets/mammals.csv', ',', 'header');
table = await loadTable('/assets/mammals.csv', ',', 'header');

table.addColumn('carnivore');
table.set(0, 'carnivore', 'no');
Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/en/p5.sound/loadSound.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ example:
<div><code>
let mySound;
function preload() {
mySound = loadSound('//assets/doorbell.mp3');
mySound = loadSound('/assets/doorbell.mp3');
}

function setup() {
Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/en/p5.sound/p5.Amplitude.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ example:

function preload() {
//replace this sound with something local with rights to distribute
sound = loadSound('//assets/Damscray_DancingTiger.mp3');
sound = loadSound('/assets/Damscray_DancingTiger.mp3');
}

function setup() {
Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/en/p5.sound/p5.Panner.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ example:
let panner, lfo, soundfile, cnv;

function preload() {
soundfile = loadSound('//assets/beat.mp3');
soundfile = loadSound('/assets/beat.mp3');
}

function setup() {
Expand Down
4 changes: 2 additions & 2 deletions src/content/reference/en/p5.sound/p5.Panner3D.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ example:
let vZ;

function preload() {
soundSource = loadSound('//assets/beat.mp3');
font = loadFont('//assets/SourceSansPro-Regular.otf');
soundSource = loadSound('/assets/beat.mp3');
font = loadFont('/assets/SourceSansPro-Regular.otf');
}

function setup() {
Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/en/p5.sound/p5.PitchShifter.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ example:
let cnv, soundFile, pitchShifter;

function preload() {
soundFile = loadSound('//assets/beatbox.mp3');
soundFile = loadSound('/assets/beatbox.mp3');
}

function setup() {
Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/en/p5.sound/p5.SoundFile.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ example:
function preload() {
//replace this sound with something local with rights to distribute
//need to fix local asset loading first though :)
sound = loadSound('//assets/doorbell.mp3');
sound = loadSound('/assets/doorbell.mp3');
}

function setup() {
Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/en/p5/async_await.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ example:

// Load the file and create a p5.Geometry object.
async function setup() {
shape = await loadModel('//assets/teapot.obj');
shape = await loadModel('/assets/teapot.obj');

createCanvas(100, 100, WEBGL);

Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/en/p5/createImg.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ example:
background(200);

let img = createImg(
'//assets/cat.jpg',
'/assets/cat.jpg',
'image of a cat'
);
img.position(0, 10);
Expand Down
2 changes: 1 addition & 1 deletion src/content/reference/en/p5/vertex.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ example:
let vid;
function setup() {
// Load a video and create a p5.MediaElement object.
vid = createVideo('//assets/fingers.mov');
vid = createVideo('/assets/fingers.mov');
createCanvas(100, 100, WEBGL);

// Hide the video.
Expand Down
4 changes: 2 additions & 2 deletions src/scripts/builders/reference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ const correctRelativeLinksToExampleAssets = (
return content;
}
return Array.isArray(content)
? content.map((ex) => ex.replaceAll("assets/", "/assets/").replaceAll(/\n$/g, ""))
: content.replaceAll("assets/", "/assets/");
? content.map((ex) => ex.replaceAll(/(?<!\/)assets\//g, "/assets/").replaceAll(/\n$/g, ""))
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

: content.replaceAll(/(?<!\/)assets\//g, "/assets/");
};

/**
Expand Down