@nyaomaru/divider 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +20 -1
- package/dist/index.js +20 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -553,9 +553,28 @@ function tryExtractQuery(input) {
|
|
|
553
553
|
const url = new URL(input);
|
|
554
554
|
return url.search.startsWith(QUERY_SEPARATORS.QUESTION_MARK) ? url.search.slice(1) : url.search;
|
|
555
555
|
} catch {
|
|
556
|
-
return input;
|
|
556
|
+
return extractQueryFromQuestionMark(input);
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
|
+
function extractQueryFromQuestionMark(input) {
|
|
560
|
+
const fragmentIndex = input.indexOf("#");
|
|
561
|
+
const withoutFragment = fragmentIndex >= 0 ? input.slice(0, fragmentIndex) : input;
|
|
562
|
+
const questionMarkIndex = withoutFragment.indexOf(
|
|
563
|
+
QUERY_SEPARATORS.QUESTION_MARK
|
|
564
|
+
);
|
|
565
|
+
if (questionMarkIndex < 0) {
|
|
566
|
+
return withoutFragment;
|
|
567
|
+
}
|
|
568
|
+
if (questionMarkIndex === 0) {
|
|
569
|
+
return withoutFragment.slice(1);
|
|
570
|
+
}
|
|
571
|
+
const prefix = withoutFragment.slice(0, questionMarkIndex);
|
|
572
|
+
const hasQuerySeparatorBefore = prefix.includes(QUERY_SEPARATORS.AMPERSAND) || prefix.includes(QUERY_SEPARATORS.EQUALS);
|
|
573
|
+
if (hasQuerySeparatorBefore) {
|
|
574
|
+
return withoutFragment;
|
|
575
|
+
}
|
|
576
|
+
return withoutFragment.slice(questionMarkIndex + 1);
|
|
577
|
+
}
|
|
559
578
|
function stripLeadingQuestionMark(query) {
|
|
560
579
|
return query.startsWith(QUERY_SEPARATORS.QUESTION_MARK) ? query.slice(1) : query;
|
|
561
580
|
}
|
package/dist/index.js
CHANGED
|
@@ -519,9 +519,28 @@ function tryExtractQuery(input) {
|
|
|
519
519
|
const url = new URL(input);
|
|
520
520
|
return url.search.startsWith(QUERY_SEPARATORS.QUESTION_MARK) ? url.search.slice(1) : url.search;
|
|
521
521
|
} catch {
|
|
522
|
-
return input;
|
|
522
|
+
return extractQueryFromQuestionMark(input);
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
|
+
function extractQueryFromQuestionMark(input) {
|
|
526
|
+
const fragmentIndex = input.indexOf("#");
|
|
527
|
+
const withoutFragment = fragmentIndex >= 0 ? input.slice(0, fragmentIndex) : input;
|
|
528
|
+
const questionMarkIndex = withoutFragment.indexOf(
|
|
529
|
+
QUERY_SEPARATORS.QUESTION_MARK
|
|
530
|
+
);
|
|
531
|
+
if (questionMarkIndex < 0) {
|
|
532
|
+
return withoutFragment;
|
|
533
|
+
}
|
|
534
|
+
if (questionMarkIndex === 0) {
|
|
535
|
+
return withoutFragment.slice(1);
|
|
536
|
+
}
|
|
537
|
+
const prefix = withoutFragment.slice(0, questionMarkIndex);
|
|
538
|
+
const hasQuerySeparatorBefore = prefix.includes(QUERY_SEPARATORS.AMPERSAND) || prefix.includes(QUERY_SEPARATORS.EQUALS);
|
|
539
|
+
if (hasQuerySeparatorBefore) {
|
|
540
|
+
return withoutFragment;
|
|
541
|
+
}
|
|
542
|
+
return withoutFragment.slice(questionMarkIndex + 1);
|
|
543
|
+
}
|
|
525
544
|
function stripLeadingQuestionMark(query) {
|
|
526
545
|
return query.startsWith(QUERY_SEPARATORS.QUESTION_MARK) ? query.slice(1) : query;
|
|
527
546
|
}
|