50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
import {
|
|
asciiAlphanumeric,
|
|
codes,
|
|
values
|
|
} from "./chunk-QZZOH36M.js";
|
|
|
|
// node_modules/micromark-util-sanitize-uri/dev/index.js
|
|
function normalizeUri(value) {
|
|
const result = [];
|
|
let index = -1;
|
|
let start = 0;
|
|
let skip = 0;
|
|
while (++index < value.length) {
|
|
const code = value.charCodeAt(index);
|
|
let replace = "";
|
|
if (code === codes.percentSign && asciiAlphanumeric(value.charCodeAt(index + 1)) && asciiAlphanumeric(value.charCodeAt(index + 2))) {
|
|
skip = 2;
|
|
} else if (code < 128) {
|
|
if (!/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(code))) {
|
|
replace = String.fromCharCode(code);
|
|
}
|
|
} else if (code > 55295 && code < 57344) {
|
|
const next = value.charCodeAt(index + 1);
|
|
if (code < 56320 && next > 56319 && next < 57344) {
|
|
replace = String.fromCharCode(code, next);
|
|
skip = 1;
|
|
} else {
|
|
replace = values.replacementCharacter;
|
|
}
|
|
} else {
|
|
replace = String.fromCharCode(code);
|
|
}
|
|
if (replace) {
|
|
result.push(value.slice(start, index), encodeURIComponent(replace));
|
|
start = index + skip + 1;
|
|
replace = "";
|
|
}
|
|
if (skip) {
|
|
index += skip;
|
|
skip = 0;
|
|
}
|
|
}
|
|
return result.join("") + value.slice(start);
|
|
}
|
|
|
|
export {
|
|
normalizeUri
|
|
};
|
|
//# sourceMappingURL=chunk-GUZKZG7N.js.map
|