@@ -378,6 +378,16 @@ public String toString() {
378378 * @since 1.0.0
379379 */
380380 public String canonicalize () {
381+ return canonicalize (false );
382+ }
383+
384+ /**
385+ * Returns the canonicalized representation of the purl.
386+ *
387+ * @return the canonicalized representation of the purl
388+ * @since 1.3.2
389+ */
390+ private String canonicalize (boolean coordinatesOnly ) {
381391 if (canonicalizedForm != null ) {
382392 return canonicalizedForm ;
383393 }
@@ -397,18 +407,20 @@ public String canonicalize() {
397407 if (version != null ) {
398408 purl .append ("@" ).append (percentEncode (version ));
399409 }
400- if (qualifiers != null && qualifiers .size () > 0 ) {
401- purl .append ("?" );
402- qualifiers .entrySet ().stream ().forEachOrdered ((entry ) -> {
403- purl .append (entry .getKey ().toLowerCase ());
404- purl .append ("=" );
405- purl .append (percentEncode (entry .getValue ()));
406- purl .append ("&" );
407- });
408- purl .setLength (purl .length () - 1 );
409- }
410- if (subpath != null ) {
411- purl .append ("#" ).append (encodePath (subpath ));
410+ if (! coordinatesOnly ) {
411+ if (qualifiers != null && qualifiers .size () > 0 ) {
412+ purl .append ("?" );
413+ qualifiers .entrySet ().stream ().forEachOrdered ((entry ) -> {
414+ purl .append (entry .getKey ().toLowerCase ());
415+ purl .append ("=" );
416+ purl .append (percentEncode (entry .getValue ()));
417+ purl .append ("&" );
418+ });
419+ purl .setLength (purl .length () - 1 );
420+ }
421+ if (subpath != null ) {
422+ purl .append ("#" ).append (encodePath (subpath ));
423+ }
412424 }
413425 canonicalizedForm = purl .toString ();
414426 return canonicalizedForm ;
@@ -594,19 +606,47 @@ private String encodePath(final String path) {
594606 * Evaluates if the specified Package URL has the same values up to, but excluding
595607 * the qualifier (querystring). This includes equivalence of: scheme, type, namespace,
596608 * name, and version, but excludes qualifier and subpath from evaluation.
609+ * @deprecated
610+ * This method is no longer recommended and will be removed from a future release.
611+ * <p> Use {@link PackageURL#isCoordinatesEquals} instead.</p>
597612 *
598613 * @param purl the Package URL to evaluate
599614 * @return true if equivalence passes, false if not
600615 * @since 1.2.0
601616 */
617+ //@Deprecated(since = "1.4.0", forRemoval = true)
618+ @ Deprecated
602619 public boolean isBaseEquals (final PackageURL purl ) {
620+ return isCoordinatesEquals (purl );
621+ }
622+
623+ /**
624+ * Evaluates if the specified Package URL has the same values up to, but excluding
625+ * the qualifier (querystring). This includes equivalence of: scheme, type, namespace,
626+ * name, and version, but excludes qualifier and subpath from evaluation.
627+ *
628+ * @param purl the Package URL to evaluate
629+ * @return true if equivalence passes, false if not
630+ * @since 1.4.0
631+ */
632+ public boolean isCoordinatesEquals (final PackageURL purl ) {
603633 return Objects .equals (scheme , purl .scheme ) &&
604634 Objects .equals (type , purl .type ) &&
605635 Objects .equals (namespace , purl .namespace ) &&
606636 Objects .equals (name , purl .name ) &&
607637 Objects .equals (version , purl .version );
608638 }
609639
640+ /**
641+ * Returns only the canonicalized coordinates of the Package URL which includes the type, namespace, name,
642+ * and version, and which omits the qualifier and subpath.
643+ * @return A canonicalized PackageURL String excluding the qualifier and subpath.
644+ * @since 1.4.0
645+ */
646+ public String getCoordinates () {
647+ return canonicalize (true );
648+ }
649+
610650 /**
611651 * Evaluates if the specified Package URL has the same canonical value. This method
612652 * canonicalizes the Package URLs being evaluated and performs an equivalence on the
0 commit comments