CocoaPods / cocoapods.org

That website https://cocoapods.org/ - pretty useful
53 stars 47 forks source link

“See Podspec” links broken on cocoapods.org #484

Closed capnslipp closed 6 months ago

capnslipp commented 1 year ago

The “See Podspec” link on every individual pod page on cocoapods.org currently has a broken link, appearing to be spitting out raw Ruby code in the middle of the URL.

For example, on https://cocoapods.org/pods/Mapbox-iOS-SDK, the See Podspec link points to https://github.com/CocoaPods/Specs/blob/master/Specs/["a", "5", "9", "Mapbox-iOS-SDK", <Pod::Version version=6.4.1>]/Mapbox-iOS-SDK.podspec.json and the generated HTML looks like this:

<ul class="links">
    <li>
        <a href="https://github.com/CocoaPods/Specs/blob/master/Specs/[&quot;a&quot;, &quot;5&quot;, &quot;9&quot;, &quot;Mapbox-iOS-SDK&quot;, &lt;Pod::Version version=6.4.1&gt;]/Mapbox-iOS-SDK.podspec.json">See Podspec</a>
    </li>
    …

Here's a GreaseMonkey script to fix the links browser-side until one of CocoaPods's very-busy unpaid volunteers gets around to fixing it:

// ==UserScript==
// @name     Fix Broken CocoaPods Link
// @version  1
// @match        https://cocoapods.org/pods/*
// ==/UserScript==

let $ = unsafeWindow.jQuery;

console.log("Running Fix Broken CocoaPods Link…");

let githubLinks = $('.links a[href^="https://github.com"]');
if (githubLinks.length >= 1) {
  let githubLink = githubLinks[0];

  let squareBracketsMatches = githubLink.href.match(/\[.+\]/);
  if (squareBracketsMatches.length >= 1) {
    let squareBracketsMatch = squareBracketsMatches[0];

    var arrayString = decodeURI(squareBracketsMatch);
    arrayString = arrayString.replace(/<Pod::Version version=(.+)>/, '"$1"');

    let array = eval(arrayString);
    let urlPiece = array.join('/');

    let newHref = githubLink.href.replace(/(\[.+\])/, urlPiece);
    githubLink.href = newHref;
  }
}

console.log("Finished Fix Broken CocoaPods Link.");
ezefranca commented 8 months ago

Related https://github.com/CocoaPods/cocoapods.org/pull/494

capnslipp commented 6 months ago

Fixed, thanks!